From 578ea4a555edbdd9d30a4221ed9ac145e1bd129f Mon Sep 17 00:00:00 2001 From: bobloy Date: Mon, 15 Mar 2021 10:31:29 -0400 Subject: [PATCH] Consistently avoid guild.icon --- qrinvite/qrinvite.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qrinvite/qrinvite.py b/qrinvite/qrinvite.py index a4c377c..684b69d 100644 --- a/qrinvite/qrinvite.py +++ b/qrinvite/qrinvite.py @@ -67,8 +67,10 @@ class QRInvite(Cog): 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) - 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 session.get(image_url) as response: image = await response.read() @@ -77,27 +79,27 @@ class QRInvite(Cog): file.write(image) 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": await ctx.maybe_send_embed("gif is not supported yet, stay tuned") return elif extension == "png": - new_path = str(image_path) + new_image_path = str(image_path) elif extension == "jpg": - new_path = convert_jpg_to_png(str(image_path)) + new_image_path = convert_jpg_to_png(str(image_path)) else: await ctx.maybe_send_embed(f"{extension} is not supported yet, stay tuned") return myqr.run( invite, - picture=new_path, - save_name=ctx.guild.icon + "_qrcode.png", + picture=new_image_path, + save_name=f"{save_as_name}_qrcode.png", save_dir=str(cog_data_path(self)), 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: await ctx.send(file=discord.File(png_path, "qrcode.png"))