Displaying the statuses vertically

Shortening Fields
Adding commentary
Capatilizing Server Region
Limiting to 20 roles
pull/8/head
sgoudham 4 years ago
parent 556e91f2a2
commit 926163efcb

@ -115,51 +115,67 @@ class GetInfo(commands.Cog):
guild_icon = ctx.guild.icon_url guild_icon = ctx.guild.icon_url
guild_id = ctx.guild.id guild_id = ctx.guild.id
# Get all the roles of the user # Check if the amount of roles is above 20
mentions = [role.mention for role in ctx.guild.roles] if len(ctx.guild.roles) > 20:
# Display the first 20 roles with a length specified telling the user how many roles were not shown
length = len(ctx.guild.roles) - 20
# Store the roles in a string called "roles" # Store the first 20 roles in a string called "roles"
# For each role that the user has (Skipping the first element as it's always going to be @everyone) # (Skipping the first element as it's always going to be @everyone)
roles = " ".join(mentions[1:]) role_string = f"{' **>>** '.join(map(str, (role.mention for role in ctx.guild.roles[1:20])))} and **{length}** more"
# Define the statuses of the members within the discord else:
statuses = [len(list(filter(lambda m: str(m.status) == "online", ctx.guild.members))), # Display all the roles in the server as it is less than 20
len(list(filter(lambda m: str(m.status) == "idle", ctx.guild.members))), role_string = f"{' **>>** '.join(map(str, (role.mention for role in ctx.guild.roles[1:])))}"
len(list(filter(lambda m: str(m.status) == "dnd", ctx.guild.members))),
len(list(filter(lambda m: str(m.status) == "offline", ctx.guild.members)))]
# Check if the list of emojis returned are greater than 20 # Check if the list of emojis returned are greater than 20
if len(ctx.guild.emojis) > 20: if len(ctx.guild.emojis) > 20:
# Display the first 20 emojis with a length specified after telling the user how many emojis were not shown # Display the first 20 emojis with a length specified telling the user how many emojis were not shown
length = len(ctx.guild.emojis) - 20 length = len(ctx.guild.emojis) - 20
emojis = f"{' '.join(map(str, ctx.guild.emojis[:20]))} and {length} more..." # Store the first 20 emojis in a string
emojis = f"{' '.join(map(str, ctx.guild.emojis[:20]))} and **{length}** more..."
else: else:
# Display all the emojis in the server as it is less than 20 # Display all the emojis in the server as it is less than 20
emojis = " ".join(map(str, ctx.guild.emojis)) emojis = " ".join(map(str, ctx.guild.emojis))
# Define the statuses of the members within the discord
statuses = [len(list(filter(lambda m: str(m.status) == "online", ctx.guild.members))),
len(list(filter(lambda m: str(m.status) == "idle", ctx.guild.members))),
len(list(filter(lambda m: str(m.status) == "dnd", ctx.guild.members))),
len(list(filter(lambda m: str(m.status) == "offline", ctx.guild.members)))]
# Set up embed to display all the server information # Set up embed to display all the server information
embed = Embed(title="**Server Information**", embed = Embed(title="**Server Information**",
description=f"**All Roles**\n\n{roles}\n",
colour=Colour(int(random.choice(colour_list))), colour=Colour(int(random.choice(colour_list))),
timestamp=time) timestamp=time)
embed.set_thumbnail(url=guild_icon) embed.set_thumbnail(url=guild_icon)
embed.set_footer(text=f"ID: {guild_id}", icon_url='{}'.format(guild_icon)) embed.set_footer(text=f"ID: {guild_id}", icon_url='{}'.format(guild_icon))
# Get the list of banned users from the server
bans = len(await ctx.guild.bans())
# Get the list of invites created for the server
invites = len(await ctx.guild.invites())
# Define fields to be added into the embed # Define fields to be added into the embed
fields = [("Owner", ctx.guild.owner, True), fields = [("Owner", ctx.guild.owner, True),
("Created", ctx.guild.created_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), False), ("Created", ctx.guild.created_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), False),
("Region", str(ctx.guild.region).upper(), False), ("Region", str(ctx.guild.region).capitalize(), False),
("Statuses", f"🟢 {statuses[0]} 🟠 {statuses[1]} 🔴 {statuses[2]}{statuses[3]}", False), ("Statuses", f"🟢 {statuses[0]} \n🟠 {statuses[1]} \n🔴 {statuses[2]} \n{statuses[3]}", False),
("Members", len(ctx.guild.members), True),
("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True), (f"Members ({len(ctx.guild.members)})",
("Bots", len(list(filter(lambda m: m.bot, ctx.guild.members))), True), f"\nHumans: {len(list(filter(lambda m: not m.bot, ctx.guild.members)))}" +
("Banned Members", len(await ctx.guild.bans()), True), f"\nBots: {len(list(filter(lambda m: m.bot, ctx.guild.members)))}" +
("Text Channels", len(ctx.guild.text_channels), True), f"\nBanned: {bans}", True),
("Voice Channels", len(ctx.guild.voice_channels), True),
("Categories", len(ctx.guild.categories), True), (f"Channels ({len(ctx.guild.channels)})",
("Roles", len(ctx.guild.roles), True), f"\nText: {len(ctx.guild.text_channels)}" +
("Invites", len(await ctx.guild.invites()), True), f"\nVoice: {len(ctx.guild.voice_channels)}", True),
("Emojis", emojis, False)]
("Misc", f"Categories: {len(ctx.guild.categories)}" +
f"\nInvites: {invites}", True),
(f"Roles ({len(ctx.guild.roles)})", role_string, True),
(f"Emojis ({len(ctx.guild.emojis)})", emojis, False)]
# Add fields to the embed # Add fields to the embed
for name, value, inline in fields: for name, value, inline in fields:

Loading…
Cancel
Save