discordbot/cogs/profile_cog.py
Slipstream 9c2bb929f7
feat: Add profile cog
This commit introduces the profile cog, which will handle user profile-related commands and functionalities.
2025-05-17 11:57:26 -06:00

31 lines
1.0 KiB
Python

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))