aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Kronifer <[email protected]>2021-06-01 14:09:16 -0500
committerGravatar Kronifer <[email protected]>2021-06-01 14:09:16 -0500
commitfcd635fe6209ce8021e6129fb1df0dd610fb451e (patch)
tree5561922c6d36b2cad1993c0caeae2cef5ee38ed1
parentchecked if user returns None (diff)
started cmd group
-rw-r--r--bot/exts/evergreen/avatar_modification/avatar_modify.py58
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: