diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/exts/evergreen/avatar_modification/_effects.py | 11 | ||||
| -rw-r--r-- | bot/exts/evergreen/avatar_modification/avatar_modify.py | 44 | 
2 files changed, 55 insertions, 0 deletions
| diff --git a/bot/exts/evergreen/avatar_modification/_effects.py b/bot/exts/evergreen/avatar_modification/_effects.py index b53b26f3..46d1a2ab 100644 --- a/bot/exts/evergreen/avatar_modification/_effects.py +++ b/bot/exts/evergreen/avatar_modification/_effects.py @@ -97,6 +97,17 @@ class PfpEffects:          return image.quantize()      @staticmethod +    def flip_effect(image: Image.Image) -> Image.Image: +        """ +        Flips the image horizontally. + +        This is done by just using ImageOps.mirror(). +        """ +        image = ImageOps.mirror(image) + +        return image + +    @staticmethod      def easterify_effect(image: Image.Image, overlay_image: t.Optional[Image.Image] = None) -> Image.Image:          """          Applies the easter effect to the given image. diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 17f34ed4..b482f42e 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -121,6 +121,50 @@ 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 + +            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 +            ) + +            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) + +            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:          """ | 
