diff options
| -rw-r--r-- | bot/exts/evergreen/avatar_modification/avatar_modify.py | 58 | 
1 files changed, 33 insertions, 25 deletions
| 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: | 
