feat: Add profile cog
This commit introduces the profile cog, which will handle user profile-related commands and functionalities.
This commit is contained in:
parent
c81793241b
commit
9c2bb929f7
30
cogs/profile_cog.py
Normal file
30
cogs/profile_cog.py
Normal file
@ -0,0 +1,30 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
class ProfileCog(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(name='avatar', help='Gets the avatar of a user in various formats.')
|
||||
async def avatar(self, ctx, member: discord.Member = None):
|
||||
"""Gets the avatar of a user in various formats."""
|
||||
if member is None:
|
||||
member = ctx.author
|
||||
|
||||
formats = ['png', 'jpg', 'webp']
|
||||
embed = discord.Embed(title=f"{member.display_name}'s Avatar")
|
||||
embed.set_image(url=member.avatar.url)
|
||||
|
||||
description = ""
|
||||
for fmt in formats:
|
||||
try:
|
||||
avatar_url = member.avatar.replace(format=fmt).url
|
||||
description += f"[{fmt.upper()}]({avatar_url})\n"
|
||||
except Exception as e:
|
||||
description += f"{fmt.upper()}: Error getting format - {e}\n"
|
||||
|
||||
embed.description = description
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ProfileCog(bot))
|
Loading…
x
Reference in New Issue
Block a user