diff options
author | 2020-02-21 12:11:12 -0800 | |
---|---|---|
committer | 2020-02-21 12:11:12 -0800 | |
commit | e3fab4567031cb0a3087b3335cd30f87e0027301 (patch) | |
tree | f54db5de9967916804cd0f0b59f3af86ebb06e26 | |
parent | API: add comment explaining class attributes (diff) |
Bot: send empty cache warning to a webhook
This is more visible than it would be if it was only logged.
* Add a webhook for the dev-log channel to constants
-rw-r--r-- | bot/bot.py | 13 | ||||
-rw-r--r-- | bot/constants.py | 1 | ||||
-rw-r--r-- | config-default.yml | 1 |
3 files changed, 12 insertions, 3 deletions
diff --git a/bot/bot.py b/bot/bot.py index e5b9717db..c818e79fb 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -68,9 +68,16 @@ class Bot(commands.Bot): return if not guild.roles or not guild.members or not guild.channels: - log.warning( - "Guild available event was dispatched but the cache appears to still be empty!" - ) + msg = "Guild available event was dispatched but the cache appears to still be empty!" + log.warning(msg) + + try: + webhook = await self.fetch_webhook(constants.Webhooks.dev_log) + except discord.HTTPException as e: + log.error(f"Failed to fetch webhook to send empty cache warning: status {e.status}") + else: + await webhook.send(f"<@&{constants.Roles.admin}> {msg}") + return self._guild_available.set() diff --git a/bot/constants.py b/bot/constants.py index 81ce3e903..9856854d7 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -406,6 +406,7 @@ class Webhooks(metaclass=YAMLGetter): big_brother: int reddit: int duck_pond: int + dev_log: int class Roles(metaclass=YAMLGetter): diff --git a/config-default.yml b/config-default.yml index 0ebdc4080..6808925c2 100644 --- a/config-default.yml +++ b/config-default.yml @@ -179,6 +179,7 @@ guild: big_brother: 569133704568373283 reddit: 635408384794951680 duck_pond: 637821475327311927 + dev_log: 680501655111729222 filter: |