From 19e0fae3ff45dc5e8a84c94638589db652ed2ad0 Mon Sep 17 00:00:00 2001 From: Matthew Flegg Date: Sun, 10 Apr 2022 23:59:30 +0100 Subject: [PATCH] added ~servericon command --- cogs/info/info_commands.py | 11 +++++++++++ cogs/info/prefix_cog/info_cog.py | 22 ++++++++++++++++++++-- cogs/info/slash_cog/info_slash_cog.py | 18 ++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/cogs/info/info_commands.py b/cogs/info/info_commands.py index 38f2f47..83da42c 100644 --- a/cogs/info/info_commands.py +++ b/cogs/info/info_commands.py @@ -151,3 +151,14 @@ async def avatar_callback( embed = discord.Embed(title=f"💡 {member.name}'s Avatar") embed.set_image(url=member.avatar.url) return await send_embed(is_interaction, embed, ctx) + + +async def servericon_callback(ctx: discord.Interaction | commands.Context): + is_interaction = isinstance(ctx, discord.Interaction) + + if is_interaction: + await ctx.response.defer() + + embed = discord.Embed(title=f"💡 {ctx.guild.name}'s Icon") + embed.set_image(url=ctx.guild.icon.url) + return await send_embed(is_interaction, embed, ctx) diff --git a/cogs/info/prefix_cog/info_cog.py b/cogs/info/prefix_cog/info_cog.py index d0d8d5d..e152873 100644 --- a/cogs/info/prefix_cog/info_cog.py +++ b/cogs/info/prefix_cog/info_cog.py @@ -95,9 +95,9 @@ async def botinfo(self, ctx: commands.Context): @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. + 💡 Shows a member's avatar. - ❓ This will change depending on whether the bot is self-hosted. + ❓ If no member is specified, it shows yours. Usage: ``` @@ -110,6 +110,24 @@ async def avatar(self, ctx: commands.Context, *, member: discord.Member = None): """ await avatar_callback(ctx, member) + @commands.command() + async def servericon(self, ctx: commands.Context): + """ + 💡 Shows the server's icon. + + ❓ This command is also available as a slash command. + + Usage: + ``` + ~avatar [@member] + ``` + Or: + ``` + /avatar [@member] + ``` + """ + await servericon_callback(ctx) + async def setup(client: commands.Bot): """ diff --git a/cogs/info/slash_cog/info_slash_cog.py b/cogs/info/slash_cog/info_slash_cog.py index b2479e3..47fd171 100644 --- a/cogs/info/slash_cog/info_slash_cog.py +++ b/cogs/info/slash_cog/info_slash_cog.py @@ -116,6 +116,24 @@ async def avatar( """ await avatar_callback(interaction, member) + @app_commands.command() + async def servericon(self, interaction: discord.Interaction): + """ + 💡 Shows the server's icon. + + ❓ This command is also available as a prefix command. + + Usage: + ``` + ~avatar [@member] + ``` + Or: + ``` + /avatar [@member] + ``` + """ + await servericon_callback(interaction) + async def setup(client: commands.Bot): """