mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
style: new code layout
This commit is contained in:
51
cogs/general/serverinfo.py
Normal file
51
cogs/general/serverinfo.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja)
|
||||
Description:
|
||||
🐍 A simple template to start to code your own and personalized Discord bot in Python
|
||||
|
||||
Version: 6.4.0
|
||||
"""
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
|
||||
class ServerInfo(commands.Cog, name="serverinfo"):
|
||||
def __init__(self, bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
@commands.hybrid_command(
|
||||
name="serverinfo",
|
||||
description="Get some useful (or not) information about the server.",
|
||||
)
|
||||
async def serverinfo(self, context: Context) -> None:
|
||||
"""
|
||||
Get some useful (or not) information about the server.
|
||||
|
||||
:param context: The hybrid command context.
|
||||
"""
|
||||
roles = [role.name for role in context.guild.roles]
|
||||
num_roles = len(roles)
|
||||
if num_roles > 50:
|
||||
roles = roles[:50]
|
||||
roles.append(f">>>> Displaying [50/{num_roles}] Roles")
|
||||
roles = ", ".join(roles)
|
||||
|
||||
embed = discord.Embed(
|
||||
title="**Server Name:**", description=f"{context.guild}", color=0xBEBEFE
|
||||
)
|
||||
if context.guild.icon is not None:
|
||||
embed.set_thumbnail(url=context.guild.icon.url)
|
||||
embed.add_field(name="Server ID", value=context.guild.id)
|
||||
embed.add_field(name="Member Count", value=context.guild.member_count)
|
||||
embed.add_field(
|
||||
name="Text/Voice Channels", value=f"{len(context.guild.channels)}"
|
||||
)
|
||||
embed.add_field(name=f"Roles ({len(context.guild.roles)})", value=roles)
|
||||
embed.set_footer(text=f"Created at: {context.guild.created_at}")
|
||||
await context.send(embed=embed)
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
await bot.add_cog(ServerInfo(bot))
|
||||
Reference in New Issue
Block a user