Consistently avoid guild.icon
This commit is contained in:
parent
920f8817d7
commit
578ea4a555
@ -67,8 +67,10 @@ class QRInvite(Cog):
|
|||||||
|
|
||||||
extension = pathlib.Path(image_url).parts[-1].replace(".", "?").split("?")[1]
|
extension = pathlib.Path(image_url).parts[-1].replace(".", "?").split("?")[1]
|
||||||
|
|
||||||
|
save_as_name = f"{ctx.guild.id}-{ctx.author.id}"
|
||||||
|
|
||||||
path: pathlib.Path = cog_data_path(self)
|
path: pathlib.Path = cog_data_path(self)
|
||||||
image_path = path / f"{ctx.guild.id}-{ctx.author.id}.{extension}"
|
image_path = path / f"{save_as_name}.{extension}"
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(image_url) as response:
|
async with session.get(image_url) as response:
|
||||||
image = await response.read()
|
image = await response.read()
|
||||||
@ -77,27 +79,27 @@ class QRInvite(Cog):
|
|||||||
file.write(image)
|
file.write(image)
|
||||||
|
|
||||||
if extension == "webp":
|
if extension == "webp":
|
||||||
new_path = convert_webp_to_png(str(image_path))
|
new_image_path = convert_webp_to_png(str(image_path))
|
||||||
elif extension == "gif":
|
elif extension == "gif":
|
||||||
await ctx.maybe_send_embed("gif is not supported yet, stay tuned")
|
await ctx.maybe_send_embed("gif is not supported yet, stay tuned")
|
||||||
return
|
return
|
||||||
elif extension == "png":
|
elif extension == "png":
|
||||||
new_path = str(image_path)
|
new_image_path = str(image_path)
|
||||||
elif extension == "jpg":
|
elif extension == "jpg":
|
||||||
new_path = convert_jpg_to_png(str(image_path))
|
new_image_path = convert_jpg_to_png(str(image_path))
|
||||||
else:
|
else:
|
||||||
await ctx.maybe_send_embed(f"{extension} is not supported yet, stay tuned")
|
await ctx.maybe_send_embed(f"{extension} is not supported yet, stay tuned")
|
||||||
return
|
return
|
||||||
|
|
||||||
myqr.run(
|
myqr.run(
|
||||||
invite,
|
invite,
|
||||||
picture=new_path,
|
picture=new_image_path,
|
||||||
save_name=ctx.guild.icon + "_qrcode.png",
|
save_name=f"{save_as_name}_qrcode.png",
|
||||||
save_dir=str(cog_data_path(self)),
|
save_dir=str(cog_data_path(self)),
|
||||||
colorized=colorized,
|
colorized=colorized,
|
||||||
)
|
)
|
||||||
|
|
||||||
png_path: pathlib.Path = path / (ctx.guild.icon + "_qrcode.png")
|
png_path: pathlib.Path = path / f"{save_as_name}_qrcode.png"
|
||||||
# with png_path.open("rb") as png_fp:
|
# with png_path.open("rb") as png_fp:
|
||||||
await ctx.send(file=discord.File(png_path, "qrcode.png"))
|
await ctx.send(file=discord.File(png_path, "qrcode.png"))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user