Advertisement
Spiral2cool

Create /serverinfo Command For Discord

Apr 19th, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | Source Code | 0 0
  1. import discord
  2. from discord.ext import commands
  3.  
  4. client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
  5.  
  6. @client.event
  7. async def on_ready():
  8. await client.tree.sync()
  9. print("Success: Bot is connected to discord.")
  10.  
  11. @client.command()
  12. async def serverinfo(ctx):
  13. info_embed = discord.Embed(title=f"Information about {ctx.guild.name}", description="All public information about this guild.", color=discord.Color.dark_blue())
  14. info_embed.set_thumbnail(url=ctx.guild.icon)
  15. info_embed.add_field(name="Name: ", value=ctx.guild.name, inline=False)
  16. info_embed.add_field(name="ID: ", value=ctx.guild.id, inline=False)
  17. info_embed.add_field(name="Owner: ", value=ctx.guild.owner.mention, inline=False)
  18. info_embed.add_field(name="Member Count: ", value=ctx.guild.member_count, inline=False)
  19. info_embed.add_field(name="Channel Count: ", value=len(ctx.guild.channels), inline=False)
  20. info_embed.add_field(name="Role Count: ", value=len(ctx.guild.roles), inline=False)
  21. info_embed.add_field(name="Rules Channel: ", value=ctx.guild.rules_channel, inline=False)
  22. info_embed.add_field(name="Booster Count: ", value=ctx.guild.premium_subscription_count, inline=False)
  23. info_embed.add_field(name="Booster Tier: ", value=ctx.guild.premium_tier, inline=False)
  24. info_embed.add_field(name="Booster Role: ", value=ctx.guild.premium_subscriber_role, inline=False)
  25. info_embed.add_field(name="Date of Creation: ", value=ctx.guild.created_at.__format__("%A, %d. %B %Y @ %H:%M:%S"), inline=False)
  26. info_embed.set_footer(text=f"Requested By: {ctx.author.name}", icon_url=ctx.author.avatar)
  27.  
  28. await ctx.send(embed=info_embed)
  29.  
  30.  
  31.  
  32.  
  33. client.run("Your Bot Token") # Replace “Your Bot Token With The Actual Bot Token”
  34.  
  35. # Need Help? Join Our Discord - https://discord.gg/tutorial
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement