2025-09-14 18:54:56 -04:00
|
|
|
import discord
|
|
|
|
|
from discord.ext import commands
|
|
|
|
|
|
2025-09-28 22:53:25 -04:00
|
|
|
def serverinfo_command():
|
2025-09-14 18:54:56 -04:00
|
|
|
@commands.hybrid_command(
|
|
|
|
|
name="serverinfo",
|
|
|
|
|
description="Get some useful (or not) information about the server.",
|
|
|
|
|
)
|
2025-09-28 22:53:25 -04:00
|
|
|
@commands.guild_only()
|
|
|
|
|
async def serverinfo(self, context):
|
2025-09-15 13:50:24 -04:00
|
|
|
if context.guild is None:
|
|
|
|
|
await context.send("This command can only be used in a server, not in DMs!")
|
|
|
|
|
return
|
|
|
|
|
|
2025-09-14 18:54:56 -04:00
|
|
|
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)
|
2025-09-15 13:50:24 -04:00
|
|
|
|
2025-09-14 18:54:56 -04:00
|
|
|
embed = discord.Embed(
|
2025-09-15 13:50:24 -04:00
|
|
|
title="**Server Name:**",
|
|
|
|
|
description=f"{context.guild}",
|
|
|
|
|
color=0x7289DA
|
|
|
|
|
).set_author(name="Server Information", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
|
|
|
|
|
2025-09-14 18:54:56 -04:00
|
|
|
if context.guild.icon is not None:
|
|
|
|
|
embed.set_thumbnail(url=context.guild.icon.url)
|
2025-09-15 13:50:24 -04:00
|
|
|
|
2025-09-14 18:54:56 -04:00
|
|
|
embed.add_field(name="Server ID", value=context.guild.id)
|
|
|
|
|
embed.add_field(name="Member Count", value=context.guild.member_count)
|
|
|
|
|
embed.add_field(
|
2025-09-15 13:50:24 -04:00
|
|
|
name="Text/Voice Channels",
|
|
|
|
|
value=f"{len(context.guild.channels)}"
|
|
|
|
|
)
|
|
|
|
|
embed.add_field(
|
|
|
|
|
name=f"Roles ({len(context.guild.roles)})",
|
|
|
|
|
value=roles
|
2025-09-14 18:54:56 -04:00
|
|
|
)
|
2025-09-15 14:45:00 -04:00
|
|
|
embed.set_footer(text=f"Created at: {context.guild.created_at.strftime('%m/%d/%Y')}")
|
2025-09-15 13:50:24 -04:00
|
|
|
|
|
|
|
|
if getattr(context, "interaction", None):
|
|
|
|
|
await context.interaction.response.send_message(embed=embed, ephemeral=True)
|
|
|
|
|
else:
|
|
|
|
|
await context.send(embed=embed)
|
2025-09-28 22:53:25 -04:00
|
|
|
|
|
|
|
|
return serverinfo
|