aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2021-01-23 17:44:56 +0800
committerGravatar kosayoda <[email protected]>2021-01-23 17:51:43 +0800
commitf612a2630b7b324b3c73a0e9188b08449b8f1401 (patch)
tree116dd32e05773f1fc389cd398a3221f86090a872
parentReduce unnecessary line splits and parameters. (diff)
Handle unloaded cogs when retrieving server info.
-rw-r--r--bot/exts/info/information.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py
index 343942109..1fa045416 100644
--- a/bot/exts/info/information.py
+++ b/bot/exts/info/information.py
@@ -53,19 +53,26 @@ class Information(Cog):
def get_extended_server_info(self) -> str:
"""Return additional server info only visible in moderation channels."""
- talentpool_count = len(self.bot.get_cog("Talentpool").watched_users)
- bb_count = len(self.bot.get_cog("Big Brother").watched_users)
+ talentpool_info = ""
+ if (cog := self.bot.get_cog("Talentpool")):
+ talentpool_info = f"Nominated: {len(cog.watched_users)}\n"
+
+ bb_info = ""
+ if (cog := self.bot.get_cog("Big Brother")):
+ bb_info = f"BB-watched: {len(cog.watched_users)}\n"
+
+ defcon_info = ""
+ if (cog := self.bot.get_cog("Defcon")):
+ defcon_status = "Enabled" if cog.enabled else "Disabled"
+ defcon_days = cog.days.days if cog.enabled else "-"
+ defcon_info = f"Defcon status: {defcon_status}\nDefcon days: {defcon_days}\n"
- 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"""
- Nominated: {talentpool_count}
- BB-watched: {bb_count}
- Defcon status: {defcon_status}
- Defcon days: {defcon_days}
+ {talentpool_info}\
+ {bb_info}\
+ {defcon_info}\
{python_general.mention} cooldown: {python_general.slowmode_delay}s
""")