From c5b4a94a2eee3efe5627d52cb656be9eb09b4ed6 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 1 Jun 2021 10:32:32 -0500 Subject: command finished --- bot/exts/evergreen/avatar_modification/avatar_modify.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 442df2f0..c4f5915e 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -121,12 +121,12 @@ class AvatarModify(commands.Cog): await ctx.send(embed=embed, file=file) - @avatar_modify.command(aliases=("flip", "mirror")) + @avatar_modify.command(name="reverse", root_aliases=("reverse",)) async def reverse(self, ctx: commands.Context, *, text: t.Optional[str]) -> None: """Either flips your profile picture or the submitted text.""" if not text: async with ctx.typing(): - user = self._fetch_user(ctx.author.id) + user = await self._fetch_user(ctx.author.id) image_bytes = await user.avatar_url_as(size=1024).read() file_name = file_safe_name("reverse_avatar", ctx.author.display_name) @@ -143,10 +143,11 @@ class AvatarModify(commands.Cog): ) embed.set_image(url=f"attachment://{file_name}") - embed.set_footer(f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) await ctx.send(embed=embed, file=file) - + else: + await ctx.send(f"> {text[::-1]}") @avatar_modify.command(aliases=("easterify",), root_aliases=("easterify", "avatareasterify")) async def avatareasterify(self, ctx: commands.Context, *colours: t.Union[discord.Colour, str]) -> None: -- cgit v1.2.3 From ef3198074d5e1bf76fa3295993e4f1031a651f0e Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 1 Jun 2021 10:38:48 -0500 Subject: Blocked mentions. --- bot/exts/evergreen/avatar_modification/avatar_modify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index c4f5915e..6789f44a 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -147,7 +147,7 @@ class AvatarModify(commands.Cog): await ctx.send(embed=embed, file=file) else: - await ctx.send(f"> {text[::-1]}") + await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) @avatar_modify.command(aliases=("easterify",), root_aliases=("easterify", "avatareasterify")) async def avatareasterify(self, ctx: commands.Context, *colours: t.Union[discord.Colour, str]) -> None: -- cgit v1.2.3 From a25b9a2fea3ba48dd1ad036018169f6261894d39 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 1 Jun 2021 11:02:34 -0500 Subject: changes asked for by chris --- bot/exts/evergreen/avatar_modification/_effects.py | 3 +-- bot/exts/evergreen/avatar_modification/avatar_modify.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/_effects.py b/bot/exts/evergreen/avatar_modification/_effects.py index 7811d148..c5e5cb86 100644 --- a/bot/exts/evergreen/avatar_modification/_effects.py +++ b/bot/exts/evergreen/avatar_modification/_effects.py @@ -97,13 +97,12 @@ class PfpEffects: return image.quantize() @staticmethod - def reverse_effect(image: Image.Image) -> Image.Image: + def flip_effect(image: Image.Image) -> Image.Image: """ Flips the image horizontally. This is done by just using ImageOps.flip(). """ - image = image.resize((1024, 1024)) image = ImageOps.mirror(image) return image diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 6789f44a..4ed7f79d 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -124,7 +124,7 @@ class AvatarModify(commands.Cog): @avatar_modify.command(name="reverse", root_aliases=("reverse",)) async def reverse(self, ctx: commands.Context, *, text: t.Optional[str]) -> None: """Either flips your profile picture or the submitted text.""" - if not text: + if text is None: async with ctx.typing(): user = await self._fetch_user(ctx.author.id) image_bytes = await user.avatar_url_as(size=1024).read() @@ -133,7 +133,7 @@ class AvatarModify(commands.Cog): file = await in_executor( PfpEffects.apply_effect, image_bytes, - PfpEffects.reverse_effect, + PfpEffects.flip_effect, file_name ) -- cgit v1.2.3 From fe529ddb89f34f8274b7c979a9508966b14c8d7f Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 1 Jun 2021 11:20:10 -0500 Subject: checked if user returns None --- bot/exts/evergreen/avatar_modification/avatar_modify.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 4ed7f79d..98f5f132 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -127,6 +127,9 @@ class AvatarModify(commands.Cog): if text is None: async with ctx.typing(): user = await self._fetch_user(ctx.author.id) + if not user: + await ctx.send(f"{Emojis.cross_mark} Could not get user info.") + return image_bytes = await user.avatar_url_as(size=1024).read() file_name = file_safe_name("reverse_avatar", ctx.author.display_name) -- cgit v1.2.3 From 2c63f7fd419c506568e705093e9478b9cf29f4a8 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 1 Jun 2021 11:30:09 -0500 Subject: Small docstring change. Co-authored-by: ChrisJL --- bot/exts/evergreen/avatar_modification/_effects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/_effects.py b/bot/exts/evergreen/avatar_modification/_effects.py index c5e5cb86..46d1a2ab 100644 --- a/bot/exts/evergreen/avatar_modification/_effects.py +++ b/bot/exts/evergreen/avatar_modification/_effects.py @@ -101,7 +101,7 @@ class PfpEffects: """ Flips the image horizontally. - This is done by just using ImageOps.flip(). + This is done by just using ImageOps.mirror(). """ image = ImageOps.mirror(image) -- cgit v1.2.3 From fcd635fe6209ce8021e6129fb1df0dd610fb451e Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 1 Jun 2021 14:09:16 -0500 Subject: started cmd group --- .../evergreen/avatar_modification/avatar_modify.py | 58 ++++++++++++---------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 98f5f132..526ad3d0 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -121,36 +121,44 @@ class AvatarModify(commands.Cog): await ctx.send(embed=embed, file=file) - @avatar_modify.command(name="reverse", root_aliases=("reverse",)) - async def reverse(self, ctx: commands.Context, *, text: t.Optional[str]) -> None: - """Either flips your profile picture or the submitted text.""" - if text is None: - async with ctx.typing(): - user = await self._fetch_user(ctx.author.id) - if not user: - await ctx.send(f"{Emojis.cross_mark} Could not get user info.") - return - image_bytes = await user.avatar_url_as(size=1024).read() - file_name = file_safe_name("reverse_avatar", ctx.author.display_name) + @avatar_modify.group(name="reverse") + async def reverse(self, ctx: commands.Context) -> None: + if not ctx.invoked_subcommand: + await invoke_help_command(ctx) - file = await in_executor( - PfpEffects.apply_effect, - image_bytes, - PfpEffects.flip_effect, - file_name - ) + @reverse.command(name="text") + async def text(self, ctx: commands.Context, *, text: str) -> None: + """Sends the given text backwards.""" + await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) - embed = discord.Embed( - title="Your reversed avatar", - description="Here is your avatar. I think it's a spitting image of you." - ) + @reverse.command(name="image") + async def image(self, ctx: commands.Context) -> None: + """Sends a reversed version of the users profile picture.""" + async with ctx.typing(): + user = self._fetch_user(ctx.author.id) + if not user: + await ctx.send(f"{Emojis.cross_mark} Could not get user info.") + return + + image_bytes = await user.avatar_url_as(size=1024).read() + filename = file_safe_name("reverse_avatar", ctx.author.display_name) - embed.set_image(url=f"attachment://{file_name}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + file = await in_executor( + PfpEffects.apply_effect, + image_bytes, + PfpEffects.flip_effect, + filename + ) + + embed = discord.Embed( + title="Your reversed avatar.", + description="Here is your reversed avatar. I think it is a spitting image of you." + ) + + embed.set_image(f"attachment://{filename}") + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) await ctx.send(embed=embed, file=file) - else: - await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) @avatar_modify.command(aliases=("easterify",), root_aliases=("easterify", "avatareasterify")) async def avatareasterify(self, ctx: commands.Context, *colours: t.Union[discord.Colour, str]) -> None: -- cgit v1.2.3 From 5be1c59450c363b5f4483d3e46a82780ea229632 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 2 Jun 2021 09:51:00 -0500 Subject: Finished extra functionality --- .../evergreen/avatar_modification/avatar_modify.py | 50 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 526ad3d0..940ff69e 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -9,6 +9,7 @@ from concurrent.futures import ThreadPoolExecutor from pathlib import Path import discord +from PIL import UnidentifiedImageError from aiohttp import client_exceptions from discord.ext import commands @@ -121,8 +122,9 @@ class AvatarModify(commands.Cog): await ctx.send(embed=embed, file=file) - @avatar_modify.group(name="reverse") + @avatar_modify.group(name="reverse", root_aliases=['reverse']) async def reverse(self, ctx: commands.Context) -> None: + """Group for the reverse commands.""" if not ctx.invoked_subcommand: await invoke_help_command(ctx) @@ -132,14 +134,48 @@ class AvatarModify(commands.Cog): await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) @reverse.command(name="image") - async def image(self, ctx: commands.Context) -> None: - """Sends a reversed version of the users profile picture.""" + async def photo(self, ctx: commands.Context) -> None: + """ + Sends a reversed version of the users profile picture. + + If an image is attached, the given image will be flipped. + """ async with ctx.typing(): - user = self._fetch_user(ctx.author.id) + user = await self._fetch_user(ctx.author.id) if not user: await ctx.send(f"{Emojis.cross_mark} Could not get user info.") return - + if ctx.message.attachments: + url = str(ctx.message.attachments[0]) + async with self.bot.http_session.get(url) as r: + image_bytes = await r.read() + filename = file_safe_name("reverse_image", ctx.author.display_name) + + try: + file = await in_executor( + PfpEffects.apply_effect, + image_bytes, + PfpEffects.flip_effect, + filename + ) + except UnidentifiedImageError: + raise commands.BadArgument( + "The attachment given is not an image. Please ensure you send an image." + ) + return + + embed = discord.Embed( + title="Your reversed image.", + description="Here is your reversed image. I think it looks somewhat flipped." + ) + + embed.set_image(url=f"attachment://{filename}") + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + + await ctx.send(embed=embed, file=file) + + return + image_bytes = await user.avatar_url_as(size=1024).read() filename = file_safe_name("reverse_avatar", ctx.author.display_name) @@ -151,11 +187,11 @@ class AvatarModify(commands.Cog): ) embed = discord.Embed( - title="Your reversed avatar.", + title="Your reversed avatar.", description="Here is your reversed avatar. I think it is a spitting image of you." ) - embed.set_image(f"attachment://{filename}") + embed.set_image(url=f"attachment://{filename}") embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) await ctx.send(embed=embed, file=file) -- cgit v1.2.3 From 132af40b9a4d17252dfb77f38e41eee0d0e90980 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Fri, 4 Jun 2021 14:18:57 -0500 Subject: Small renaming Co-authored-by: ChrisJL --- bot/exts/evergreen/avatar_modification/avatar_modify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 940ff69e..952f2350 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -129,7 +129,7 @@ class AvatarModify(commands.Cog): await invoke_help_command(ctx) @reverse.command(name="text") - async def text(self, ctx: commands.Context, *, text: str) -> None: + async def reverse_text(self, ctx: commands.Context, *, text: str) -> None: """Sends the given text backwards.""" await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) -- cgit v1.2.3 From c866096a06ac35c751c1b1ec66de5e525f1ec5e4 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Fri, 4 Jun 2021 14:19:17 -0500 Subject: Another rename Co-authored-by: ChrisJL --- bot/exts/evergreen/avatar_modification/avatar_modify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 952f2350..154fe5de 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -134,7 +134,7 @@ class AvatarModify(commands.Cog): await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) @reverse.command(name="image") - async def photo(self, ctx: commands.Context) -> None: + async def reverse_photo(self, ctx: commands.Context) -> None: """ Sends a reversed version of the users profile picture. -- cgit v1.2.3 From 9ecaf7cbad9e34da467fa2612b81ff407ec227df Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Fri, 4 Jun 2021 14:19:44 -0500 Subject: Removed the file upload Co-authored-by: ChrisJL --- .../evergreen/avatar_modification/avatar_modify.py | 30 ---------------------- 1 file changed, 30 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 154fe5de..9356a9e7 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -145,36 +145,6 @@ class AvatarModify(commands.Cog): if not user: await ctx.send(f"{Emojis.cross_mark} Could not get user info.") return - if ctx.message.attachments: - url = str(ctx.message.attachments[0]) - async with self.bot.http_session.get(url) as r: - image_bytes = await r.read() - filename = file_safe_name("reverse_image", ctx.author.display_name) - - try: - file = await in_executor( - PfpEffects.apply_effect, - image_bytes, - PfpEffects.flip_effect, - filename - ) - except UnidentifiedImageError: - raise commands.BadArgument( - "The attachment given is not an image. Please ensure you send an image." - ) - return - - embed = discord.Embed( - title="Your reversed image.", - description="Here is your reversed image. I think it looks somewhat flipped." - ) - - embed.set_image(url=f"attachment://{filename}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) - - await ctx.send(embed=embed, file=file) - - return image_bytes = await user.avatar_url_as(size=1024).read() filename = file_safe_name("reverse_avatar", ctx.author.display_name) -- cgit v1.2.3 From 19b647f1f2613fe5f1cce006d9bf2f20ec8765c1 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Mon, 7 Jun 2021 09:19:05 -0500 Subject: Removed import --- bot/exts/evergreen/avatar_modification/avatar_modify.py | 1 - 1 file changed, 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 9356a9e7..b482f42e 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -9,7 +9,6 @@ from concurrent.futures import ThreadPoolExecutor from pathlib import Path import discord -from PIL import UnidentifiedImageError from aiohttp import client_exceptions from discord.ext import commands -- cgit v1.2.3 From 5ea96aabd779f7445b6db5236018b2b28b11a5dc Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Mon, 16 Aug 2021 10:39:29 -0500 Subject: Merged .reverse into one command and made reversing the users profile picture the default behavior --- .../evergreen/avatar_modification/avatar_modify.py | 66 +++++++++------------- 1 file changed, 28 insertions(+), 38 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index b482f42e..ccbefbd7 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -121,49 +121,39 @@ class AvatarModify(commands.Cog): await ctx.send(embed=embed, file=file) - @avatar_modify.group(name="reverse", root_aliases=['reverse']) - async def reverse(self, ctx: commands.Context) -> None: - """Group for the reverse commands.""" - if not ctx.invoked_subcommand: - await invoke_help_command(ctx) - - @reverse.command(name="text") - async def reverse_text(self, ctx: commands.Context, *, text: str) -> None: - """Sends the given text backwards.""" - await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) - - @reverse.command(name="image") - async def reverse_photo(self, ctx: commands.Context) -> None: - """ - Sends a reversed version of the users profile picture. - - If an image is attached, the given image will be flipped. - """ - async with ctx.typing(): - user = await self._fetch_user(ctx.author.id) - if not user: - await ctx.send(f"{Emojis.cross_mark} Could not get user info.") - return + @avatar_modify.command(name="reverse", root_aliases=("reverse",)) + async def reverse(self, ctx: commands.Context, *, text: t.Optional[str]): + """Reverses the sent text. + + If no text is provided, the user's profile picture will be reversed.""" + if not text: + async with ctx.typing(): + user = await self._fetch_user(ctx.author.id) + if not user: + await ctx.send(f"{Emojis.cross_mark} Could not get user info.") + return - image_bytes = await user.avatar_url_as(size=1024).read() - filename = file_safe_name("reverse_avatar", ctx.author.display_name) + image_bytes = await user.avatar_url_as(size=1024).read() + filename = file_safe_name("reverse_avatar", ctx.author.display_name) - file = await in_executor( - PfpEffects.apply_effect, - image_bytes, - PfpEffects.flip_effect, - filename - ) + file = await in_executor( + PfpEffects.apply_effect, + image_bytes, + PfpEffects.flip_effect, + filename + ) - embed = discord.Embed( - title="Your reversed avatar.", - description="Here is your reversed avatar. I think it is a spitting image of you." - ) + embed = discord.Embed( + title="Your reversed avatar.", + description="Here is your reversed avatar. I think it is a spitting image of you." + ) - embed.set_image(url=f"attachment://{filename}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + embed.set_image(url=f"attachment://{filename}") + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) - await ctx.send(embed=embed, file=file) + await ctx.send(embed=embed, file=file) + else: + await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) @avatar_modify.command(aliases=("easterify",), root_aliases=("easterify", "avatareasterify")) async def avatareasterify(self, ctx: commands.Context, *colours: t.Union[discord.Colour, str]) -> None: -- cgit v1.2.3 From 6190278321112cf131485a4791e4711f27bd7952 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Mon, 16 Aug 2021 10:41:48 -0500 Subject: lint fix because precommit didn't run --- bot/exts/evergreen/avatar_modification/avatar_modify.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index ccbefbd7..5decfce4 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -122,10 +122,12 @@ class AvatarModify(commands.Cog): await ctx.send(embed=embed, file=file) @avatar_modify.command(name="reverse", root_aliases=("reverse",)) - async def reverse(self, ctx: commands.Context, *, text: t.Optional[str]): - """Reverses the sent text. - - If no text is provided, the user's profile picture will be reversed.""" + async def reverse(self, ctx: commands.Context, *, text: t.Optional[str]) -> None: + """ + Reverses the sent text. + + If no text is provided, the user's profile picture will be reversed. + """ if not text: async with ctx.typing(): user = await self._fetch_user(ctx.author.id) -- cgit v1.2.3 From 12b562ef9a6fd2cf3015156eb738ee765f82d070 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Mon, 16 Aug 2021 16:39:52 -0500 Subject: Removed a massive it block --- .../evergreen/avatar_modification/avatar_modify.py | 47 +++++++++++----------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 5decfce4..185cdb38 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -128,34 +128,35 @@ class AvatarModify(commands.Cog): If no text is provided, the user's profile picture will be reversed. """ - if not text: - async with ctx.typing(): - user = await self._fetch_user(ctx.author.id) - if not user: - await ctx.send(f"{Emojis.cross_mark} Could not get user info.") - return + if text: + await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) + return + + async with ctx.typing(): + user = await self._fetch_user(ctx.author.id) + if not user: + await ctx.send(f"{Emojis.cross_mark} Could not get user info.") + return - image_bytes = await user.avatar_url_as(size=1024).read() - filename = file_safe_name("reverse_avatar", ctx.author.display_name) + image_bytes = await user.avatar_url_as(size=1024).read() + filename = file_safe_name("reverse_avatar", ctx.author.display_name) - file = await in_executor( - PfpEffects.apply_effect, - image_bytes, - PfpEffects.flip_effect, - filename - ) + file = await in_executor( + PfpEffects.apply_effect, + image_bytes, + PfpEffects.flip_effect, + filename + ) - embed = discord.Embed( - title="Your reversed avatar.", - description="Here is your reversed avatar. I think it is a spitting image of you." - ) + embed = discord.Embed( + title="Your reversed avatar.", + description="Here is your reversed avatar. I think it is a spitting image of you." + ) - embed.set_image(url=f"attachment://{filename}") - embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) + embed.set_image(url=f"attachment://{filename}") + embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=user.avatar_url) - await ctx.send(embed=embed, file=file) - else: - await ctx.send(f"> {text[::-1]}", allowed_mentions=discord.AllowedMentions.none()) + await ctx.send(embed=embed, file=file) @avatar_modify.command(aliases=("easterify",), root_aliases=("easterify", "avatareasterify")) async def avatareasterify(self, ctx: commands.Context, *colours: t.Union[discord.Colour, str]) -> None: -- cgit v1.2.3