aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/info/information.py7
-rw-r--r--bot/utils/helpers.py11
2 files changed, 16 insertions, 2 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py
index bb713eef1..eef18298c 100644
--- a/bot/exts/info/information.py
+++ b/bot/exts/info/information.py
@@ -17,8 +17,10 @@ from bot.decorators import in_whitelist
from bot.pagination import LinePaginator
from bot.utils.channel import is_mod_channel, is_staff_channel
from bot.utils.checks import cooldown_with_role_bypass, has_no_roles_check, in_whitelist_check
+from bot.utils.helpers import join_role_stats
from bot.utils.time import TimestampFormats, discord_timestamp, humanize_delta
+
log = logging.getLogger(__name__)
@@ -50,7 +52,10 @@ class Information(Cog):
constants.Roles.owners, constants.Roles.contributors,
)
)
- return {role.name.title(): len(role.members) for role in roles}
+ role_stats = {role.name.title(): len(role.members) for role in roles}
+ role_stats.update(
+ **join_role_stats([constants.Roles.project_leads, constants.Roles.domain_leads], "Leads", guild))
+ return role_stats
def get_extended_server_info(self, ctx: Context) -> str:
"""Return additional server info only visible in moderation channels."""
diff --git a/bot/utils/helpers.py b/bot/utils/helpers.py
index 3501a3933..b0d17c3b8 100644
--- a/bot/utils/helpers.py
+++ b/bot/utils/helpers.py
@@ -1,6 +1,7 @@
from abc import ABCMeta
-from typing import Optional
+from typing import Dict, List, Optional
+from discord import Guild
from discord.ext.commands import CogMeta
@@ -30,3 +31,11 @@ def has_lines(string: str, count: int) -> bool:
def pad_base64(data: str) -> str:
"""Return base64 `data` with padding characters to ensure its length is a multiple of 4."""
return data + "=" * (-len(data) % 4)
+
+
+def join_role_stats(role_ids: List[int], name: str, guild: Guild) -> Dict[str, int]:
+ """Return a dict object with the number of `members` of each role given, and the `name` for this joined group."""
+ members = []
+ for role_id in role_ids:
+ members += guild.get_role(role_id).members
+ return {name: len(set(members))}