Skip to content

Commit 24c9058

Browse files
authored
Merge pull request #41 from matthewflegg/feature/avatar-command
added ~avatar command
2 parents eb76fc7 + e1283e3 commit 24c9058

File tree

3 files changed

+62
-12
lines changed

3 files changed

+62
-12
lines changed

cogs/info/info_commands.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,19 @@ async def botinfo_callback(ctx: discord.Interaction | commands.Context, client:
135135
)
136136

137137
return await send_embed(is_interaction, embed, ctx)
138+
139+
140+
async def avatar_callback(
141+
ctx: discord.Interaction | commands.Context, member: discord.Member
142+
):
143+
is_interaction = isinstance(ctx, discord.Interaction)
144+
145+
if is_interaction:
146+
await ctx.response.defer()
147+
148+
if member is None:
149+
member = ctx.user if is_interaction else ctx.author
150+
151+
embed = discord.Embed(title=f"💡 {member.name}'s Avatar")
152+
embed.set_image(url=member.avatar.url)
153+
return await send_embed(is_interaction, embed, ctx)

cogs/info/prefix_cog/info_cog.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def __init__(self, client: Client) -> None:
1616

1717
@commands.command()
1818
@commands.guild_only()
19-
async def joined(
20-
self, interaction: discord.Interaction, *, member: discord.Member = None
21-
):
19+
async def joined(self, ctx: commands.Context, *, member: discord.Member = None):
2220
"""
2321
💡 Shows when a member joined the server.
2422
@@ -33,13 +31,11 @@ async def joined(
3331
/joined [@member]
3432
```
3533
"""
36-
await joined_callback(interaction, member)
34+
await joined_callback(ctx, member)
3735

3836
@commands.command()
3937
@commands.guild_only()
40-
async def toprole(
41-
self, interaction: discord.Interaction, *, member: discord.Member = None
42-
):
38+
async def toprole(self, ctx: commands.Context, *, member: discord.Member = None):
4339
"""
4440
💡 Shows the top role for a member.
4541
@@ -54,12 +50,12 @@ async def toprole(
5450
/toprole [@member]
5551
```
5652
"""
57-
await toprole_callback(interaction, member)
53+
await toprole_callback(ctx, member)
5854

5955
@commands.command(alias=["perms"])
6056
@commands.guild_only()
6157
async def permissions(
62-
self, interaction: discord.Interaction, *, member: discord.Member = None
58+
self, ctx: commands.Context, *, member: discord.Member = None
6359
):
6460
"""
6561
💡 Shows the permissions for a member.
@@ -75,11 +71,11 @@ async def permissions(
7571
/permissions [@member]
7672
```
7773
"""
78-
await perms_callback(interaction, member)
74+
await perms_callback(ctx, member)
7975

8076
@commands.command()
8177
@commands.guild_only()
82-
async def botinfo(self, interaction: discord.Interaction):
78+
async def botinfo(self, ctx: commands.Context):
8379
"""
8480
💡 Shows information about the bot.
8581
@@ -94,8 +90,25 @@ async def botinfo(self, interaction: discord.Interaction):
9490
/botinfo [@member]
9591
```
9692
"""
97-
await botinfo_callback(interaction, self.client)
93+
await botinfo_callback(ctx, self.client)
94+
95+
@commands.command()
96+
async def avatar(self, ctx: commands.Context, *, member: discord.Member = None):
97+
"""
98+
💡 Shows a member's avatar. If no member is specified, it shows yours.
99+
100+
❓ This will change depending on whether the bot is self-hosted.
98101
102+
Usage:
103+
```
104+
~avatar [@member]
105+
```
106+
Or:
107+
```
108+
/avatar [@member]
109+
```
110+
"""
111+
await avatar_callback(ctx, member)
99112

100113

101114
async def setup(client: commands.Bot):

cogs/info/slash_cog/info_slash_cog.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ async def botinfo(self, interaction: discord.Interaction):
9595
"""
9696
await botinfo_callback(interaction, self.client)
9797

98+
@app_commands.command()
99+
@app_commands.describe(member="💡 Choose a user to display the avatar of.")
100+
async def avatar(
101+
self, interaction: discord.Interaction, *, member: discord.Member = None
102+
):
103+
"""
104+
💡 Shows a member's avatar. If no member is specified, it shows yours.
105+
106+
❓ This will change depending on whether the bot is self-hosted.
107+
108+
Usage:
109+
```
110+
~avatar [@member]
111+
```
112+
Or:
113+
```
114+
/avatar [@member]
115+
```
116+
"""
117+
await avatar_callback(interaction, member)
118+
98119

99120
async def setup(client: commands.Bot):
100121
"""

0 commit comments

Comments
 (0)