aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2020-05-29 23:52:56 +0200
committerGravatar Leon Sandøy <[email protected]>2020-05-29 23:52:56 +0200
commitaa46d01fa6c6fd14a9613412783ce377fe7e967d (patch)
tree0386989d455b9fa995d7118cc6500cb7790f69f3
parentMerge pull request #966 from python-discord/sebastiaan/help-channels/ratelimits (diff)
Clean up channel counts and add staff channels.
Cleaning up a particularly dirty line by turning it into like 10 lines, and also adding the number of channels that are hidden to the `@everyone` role - which we're classifying as "Staff channels".
-rw-r--r--bot/cogs/information.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/bot/cogs/information.py b/bot/cogs/information.py
index f0eb3a1ea..8309cff4b 100644
--- a/bot/cogs/information.py
+++ b/bot/cogs/information.py
@@ -104,8 +104,27 @@ class Information(Cog):
member_count = ctx.guild.member_count
# How many of each type of channel?
- channels = Counter(c.type for c in ctx.guild.channels)
- channel_counts = "".join(sorted(f"{str(ch).title()} channels: {channels[ch]}\n" for ch in channels)).strip()
+ channel_counter = Counter(c.type for c in ctx.guild.channels)
+ channel_type_list = []
+ for channel in channel_counter:
+ channel_type = str(channel).title()
+ channel_type_list.append(f"{channel_type} channels: {channel_counter[channel]}")
+
+ channel_type_list = sorted(channel_type_list)
+ channel_counts = "\n".join(channel_type_list).strip()
+
+ # How many channels are for staff only?
+ everyone_role = ctx.guild.roles[0]
+ hidden_channels = 0
+
+ for channel in ctx.guild.channels:
+ overwrites = channel.overwrites_for(everyone_role)
+ if overwrites.is_empty():
+ continue
+
+ for perm, value in overwrites:
+ if perm == 'read_messages' and value is False:
+ hidden_channels += 1
# How many of each user status?
statuses = Counter(member.status for member in ctx.guild.members)
@@ -126,6 +145,7 @@ class Information(Cog):
Members: {member_count:,}
Roles: {roles}
$channel_counts
+ Staff channels: {hidden_channels}
**Members**
{constants.Emojis.status_online} {statuses[Status.online]:,}