diff options
| author | 2020-09-21 23:01:52 +0800 | |
|---|---|---|
| committer | 2020-09-21 23:02:48 +0800 | |
| commit | dcc1f5496765e761e91306cac69916cb9f11b4b0 (patch) | |
| tree | 89b6fa077ae13030a696b5120a310c3cab4f5134 | |
| parent | Add more role information to server embed. (diff) | |
Add extended information to !server.
Includes useful information like the number of nominated/watched
members, number of unverified members, defcon status etc.
Will not show up if the command is ran outside of a moderation channel.
| -rw-r--r-- | bot/exts/info/information.py | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py index d68dc06da..82bccb84a 100644 --- a/bot/exts/info/information.py +++ b/bot/exts/info/information.py @@ -73,6 +73,27 @@ class Information(Cog): member_counts["roles"] = len(guild.roles) - 1 # Exclude @everyone return member_counts + def get_extended_server_info(self, guild: Guild) -> str: + """Return additional server info only visible in moderation channels.""" + unverified_count = guild.member_count - len(guild.get_role(constants.Roles.verified).members) + talentpool_count = len(self.bot.get_cog("Talentpool").watched_users) + bb_count = len(self.bot.get_cog("Big Brother").watched_users) + + defcon_cog = self.bot.get_cog("Defcon") + defcon_status = "Enabled" if defcon_cog.enabled else "Disabled" + defcon_days = defcon_cog.days.days if defcon_cog.enabled else "-" + python_general = self.bot.get_channel(constants.Channels.python_discussion) + + return textwrap.dedent(f""" + Unverified: {unverified_count:,} + Nominated: {talentpool_count} + BB-watched: {bb_count} + + Defcon status: {defcon_status} + Defcon days: {defcon_days} + {python_general.mention} cooldown: {python_general.slowmode_delay}s + """) + @with_role(*constants.MODERATION_ROLES) @command(name="roles") async def roles_info(self, ctx: Context) -> None: @@ -149,6 +170,13 @@ class Information(Cog): features = ", ".join(ctx.guild.features) region = ctx.guild.region + embed.description = textwrap.dedent(f""" + Created: {created} + Voice region: {region} + Features: {features} + """) + embed.set_thumbnail(url=ctx.guild.icon_url) + # Members total_members = ctx.guild.member_count member_counts = self.get_member_counts(ctx.guild) @@ -172,12 +200,11 @@ class Information(Cog): ) embed.add_field(name="Member Status:", value=member_status, inline=False) - embed.description = textwrap.dedent(f""" - Created: {created} - Voice region: {region} - Features: {features} - """) - embed.set_thumbnail(url=ctx.guild.icon_url) + # Additional info if ran in moderation channels + if ctx.channel.id in constants.MODERATION_CHANNELS: + embed.add_field( + name="Moderation Information:", value=self.get_extended_server_info(ctx.guild) + ) await ctx.send(embed=embed) |