userinfo.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import discord
  2. from discord.ext import commands
  3. from discord.commands import Option
  4. from discord.commands import slash_command
  5. class userinfo(commands.Cog):
  6. def __init__(self, bot: discord.Bot):
  7. self.bot = bot
  8. #Command initialization
  9. @slash_command(name="userinfo", description="Show informations of a user from this server")
  10. async def userinfo(
  11. self,
  12. ctx,
  13. user: str = Option(discord.User, "Select User"),
  14. ):
  15. if user is None:
  16. user = ctx.author
  17. elif user not in ctx.guild.members:
  18. await ctx.respond("The selected user is not a member on this Server!", ephemeral=True)
  19. return
  20. elif user == self.bot.user:
  21. await ctx.respond(f"This is me - the {self.bot.user}", ephemeral=True)
  22. return
  23. embed = discord.Embed(
  24. title=f"Information about *{user.name}*",
  25. description=f"Here you see all details about {user.mention}",
  26. color=discord.Color.blue()
  27. )
  28. time = discord.utils.format_dt(user.created_at, "R")
  29. embed.add_field(name="Account creation date", value=time, inline=False)
  30. if len(user.roles) >= 2:
  31. embed.add_field(name="Roles", value=", ".join([role.mention for role in user.roles if role.name != "@everyone"]), inline=False)
  32. else:
  33. embed.add_field(name="Roles", value="User has no roles", inline=False)
  34. embed.add_field(name="Server join date", value=discord.utils.format_dt(user.joined_at, "R"), inline=False)
  35. embed.add_field(name="User ID", value=user.id)
  36. embed.set_thumbnail(url=user.display_avatar.url)
  37. embed.set_author(name="VicePD", icon_url="https://i.imgur.com/6QteFrg.png")
  38. embed.set_footer(text="VicePD - Bot | Made by BaumSplitter41")
  39. await ctx.respond(embed=embed)
  40. def setup(bot: discord.Bot):
  41. bot.add_cog(userinfo(bot))