Skip to content

Commit

Permalink
Merge pull request #41 from matthewflegg/feature/avatar-command
Browse files Browse the repository at this point in the history
added ~avatar command
  • Loading branch information
v0idzdev authored Apr 10, 2022
2 parents eb76fc7 + e1283e3 commit 24c9058
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
16 changes: 16 additions & 0 deletions cogs/info/info_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,19 @@ async def botinfo_callback(ctx: discord.Interaction | commands.Context, client:
)

return await send_embed(is_interaction, embed, ctx)


async def avatar_callback(
ctx: discord.Interaction | commands.Context, member: discord.Member
):
is_interaction = isinstance(ctx, discord.Interaction)

if is_interaction:
await ctx.response.defer()

if member is None:
member = ctx.user if is_interaction else ctx.author

embed = discord.Embed(title=f"💡 {member.name}'s Avatar")
embed.set_image(url=member.avatar.url)
return await send_embed(is_interaction, embed, ctx)
37 changes: 25 additions & 12 deletions cogs/info/prefix_cog/info_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ def __init__(self, client: Client) -> None:

@commands.command()
@commands.guild_only()
async def joined(
self, interaction: discord.Interaction, *, member: discord.Member = None
):
async def joined(self, ctx: commands.Context, *, member: discord.Member = None):
"""
💡 Shows when a member joined the server.
Expand All @@ -33,13 +31,11 @@ async def joined(
/joined [@member]
```
"""
await joined_callback(interaction, member)
await joined_callback(ctx, member)

@commands.command()
@commands.guild_only()
async def toprole(
self, interaction: discord.Interaction, *, member: discord.Member = None
):
async def toprole(self, ctx: commands.Context, *, member: discord.Member = None):
"""
💡 Shows the top role for a member.
Expand All @@ -54,12 +50,12 @@ async def toprole(
/toprole [@member]
```
"""
await toprole_callback(interaction, member)
await toprole_callback(ctx, member)

@commands.command(alias=["perms"])
@commands.guild_only()
async def permissions(
self, interaction: discord.Interaction, *, member: discord.Member = None
self, ctx: commands.Context, *, member: discord.Member = None
):
"""
💡 Shows the permissions for a member.
Expand All @@ -75,11 +71,11 @@ async def permissions(
/permissions [@member]
```
"""
await perms_callback(interaction, member)
await perms_callback(ctx, member)

@commands.command()
@commands.guild_only()
async def botinfo(self, interaction: discord.Interaction):
async def botinfo(self, ctx: commands.Context):
"""
💡 Shows information about the bot.
Expand All @@ -94,8 +90,25 @@ async def botinfo(self, interaction: discord.Interaction):
/botinfo [@member]
```
"""
await botinfo_callback(interaction, self.client)
await botinfo_callback(ctx, self.client)

@commands.command()
async def avatar(self, ctx: commands.Context, *, member: discord.Member = None):
"""
💡 Shows a member's avatar. If no member is specified, it shows yours.
❓ This will change depending on whether the bot is self-hosted.
Usage:
```
~avatar [@member]
```
Or:
```
/avatar [@member]
```
"""
await avatar_callback(ctx, member)


async def setup(client: commands.Bot):
Expand Down
21 changes: 21 additions & 0 deletions cogs/info/slash_cog/info_slash_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ async def botinfo(self, interaction: discord.Interaction):
"""
await botinfo_callback(interaction, self.client)

@app_commands.command()
@app_commands.describe(member="💡 Choose a user to display the avatar of.")
async def avatar(
self, interaction: discord.Interaction, *, member: discord.Member = None
):
"""
💡 Shows a member's avatar. If no member is specified, it shows yours.
❓ This will change depending on whether the bot is self-hosted.
Usage:
```
~avatar [@member]
```
Or:
```
/avatar [@member]
```
"""
await avatar_callback(interaction, member)


async def setup(client: commands.Bot):
"""
Expand Down

0 comments on commit 24c9058

Please sign in to comment.