QR invite fixes
This commit is contained in:
parent
eecfb821a0
commit
50a61398e6
@ -2,13 +2,10 @@ import pathlib
|
||||
|
||||
import aiohttp
|
||||
import discord
|
||||
from PIL import Image
|
||||
|
||||
from redbot.core import Config, checks, commands
|
||||
|
||||
from redbot.core.bot import Red
|
||||
|
||||
from MyQR import myqr
|
||||
from PIL import Image
|
||||
from redbot.core import Config, commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.data_manager import cog_data_path
|
||||
|
||||
|
||||
@ -46,6 +43,11 @@ class QRInvite:
|
||||
if image_url is None:
|
||||
image_url = ctx.guild.icon_url
|
||||
|
||||
if image_url == "": # Still
|
||||
await ctx.send(
|
||||
"Could not get an image, please provide one. *(`{}help qrinvite` for details)*".format(ctx.prefix))
|
||||
return
|
||||
|
||||
extension = pathlib.Path(image_url).parts[-1].replace('.', '?').split('?')[1]
|
||||
|
||||
path: pathlib.Path = cog_data_path(self)
|
||||
@ -69,6 +71,7 @@ class QRInvite:
|
||||
with png_path.open("rb") as png_fp:
|
||||
await ctx.send(file=discord.File(png_fp.read(), "qrcode.png"))
|
||||
|
||||
|
||||
def convert_png(path):
|
||||
im = Image.open(path)
|
||||
im.load()
|
||||
@ -76,6 +79,6 @@ def convert_png(path):
|
||||
im = im.convert('RGB').convert('P', palette=Image.ADAPTIVE, colors=255)
|
||||
mask = Image.eval(alpha, lambda a: 255 if a <= 128 else 0)
|
||||
im.paste(255, mask)
|
||||
newPath = path.replace(".webp",".png")
|
||||
im.save(newPath, transparency=255)
|
||||
return newPath
|
||||
new_path = path.replace(".webp", ".png")
|
||||
im.save(new_path, transparency=255)
|
||||
return new_path
|
||||
|
Loading…
x
Reference in New Issue
Block a user