diff options
author | 2022-11-29 20:27:52 +0000 | |
---|---|---|
committer | 2022-11-29 20:27:52 +0000 | |
commit | ffcb229329cbe6efe4946fcc42c7f04ff13bd914 (patch) | |
tree | 8fa4ecd3a501a9ac1e827d422641d9d9ac177b7a | |
parent | Merge pull request #2349 from python-discord/record-help-channel-claims (diff) | |
parent | Merge branch 'main' into dont-use-removed-talentpool-cache (diff) |
Merge pull request #2344 from python-discord/dont-use-removed-talentpool-cache
Dont use removed talentpool cache
-rw-r--r-- | bot/exts/info/information.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py index 1a6cfcb59..c680da2bc 100644 --- a/bot/exts/info/information.py +++ b/bot/exts/info/information.py @@ -3,7 +3,7 @@ import pprint import textwrap from collections import defaultdict from textwrap import shorten -from typing import Any, DefaultDict, Mapping, Optional, Set, Tuple, Union +from typing import Any, DefaultDict, Mapping, Optional, Set, TYPE_CHECKING, Tuple, Union import rapidfuzz from discord import AllowedMentions, Colour, Embed, Guild, Message, Role @@ -31,6 +31,11 @@ DEFAULT_RULES_DESCRIPTION = ( " all members of the community to have read and understood these." ) +if TYPE_CHECKING: + from bot.exts.moderation.defcon import Defcon + from bot.exts.moderation.watchchannels.bigbrother import BigBrother + from bot.exts.recruitment.talentpool._cog import TalentPool + class Information(Cog): """A cog with commands for generating embeds with server info, such as server stats and user info.""" @@ -76,20 +81,23 @@ class Information(Cog): ) return role_stats - def get_extended_server_info(self, ctx: Context) -> str: + async def get_extended_server_info(self, ctx: Context) -> str: """Return additional server info only visible in moderation channels.""" talentpool_info = "" - if cog := self.bot.get_cog("Talentpool"): - num_nominated = len(cog.cache) if cog.cache else "-" + talentpool_cog: TalentPool | None = self.bot.get_cog("Talentpool") + if talentpool_cog: + num_nominated = len(await talentpool_cog.api.get_nominations(active=True)) talentpool_info = f"Nominated: {num_nominated}\n" bb_info = "" - if cog := self.bot.get_cog("Big Brother"): - bb_info = f"BB-watched: {len(cog.watched_users)}\n" + bb_cog: BigBrother | None = self.bot.get_cog("Big Brother") + if bb_cog: + bb_info = f"BB-watched: {len(bb_cog.watched_users)}\n" defcon_info = "" - if cog := self.bot.get_cog("Defcon"): - threshold = time.humanize_delta(cog.threshold) if cog.threshold else "-" + defcon_cog: Defcon | None = self.bot.get_cog("Defcon") + if defcon_cog: + threshold = time.humanize_delta(defcon_cog.threshold) if defcon_cog.threshold else "-" defcon_info = f"Defcon threshold: {threshold}\n" verification = f"Verification level: {ctx.guild.verification_level.name}\n" @@ -224,7 +232,7 @@ class Information(Cog): # Additional info if ran in moderation channels if is_mod_channel(ctx.channel): - embed.add_field(name="Moderation:", value=self.get_extended_server_info(ctx)) + embed.add_field(name="Moderation:", value=await self.get_extended_server_info(ctx)) await ctx.send(embed=embed) |