diff options
author | 2022-04-16 16:47:20 +0100 | |
---|---|---|
committer | 2022-04-18 17:46:35 +0100 | |
commit | bd0c9f7223bf1ada4ce887c0ee692090875b513f (patch) | |
tree | 762820ba4548ab558bc199f67d1205c2008e746b | |
parent | Remove usages of init_task in thread bumper cog (diff) |
Wait for mod log to load when syncing defcon settings
-rw-r--r-- | bot/exts/moderation/defcon.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bot/exts/moderation/defcon.py b/bot/exts/moderation/defcon.py index 4d0488fab..d092af6e9 100644 --- a/bot/exts/moderation/defcon.py +++ b/bot/exts/moderation/defcon.py @@ -1,3 +1,4 @@ +import asyncio import traceback from collections import namedtuple from datetime import datetime @@ -80,6 +81,21 @@ class Defcon(Cog): """On cog load, try to synchronize DEFCON settings to the API.""" log.trace("Waiting for the guild to become available before syncing.") await self.bot.wait_until_guild_available() + + # Load order isn't guaranteed, attempt to check mod log load status 3 times before erroring. + for _ in range(3): + if self.mod_log: + break + else: + await asyncio.sleep(5) + else: + log.exception("Modlog cog not loaded, aborting sync.") + await self.channel.send( + f"<@&{Roles.moderators}> <@&{Roles.devops}> **WARNING**: Unable to get DEFCON settings!" + f"\n\nmod log cog could not be found after 3 tries." + ) + return + self.channel = await self.bot.fetch_channel(Channels.defcon) log.trace("Syncing settings.") |