diff options
| author | 2020-02-28 08:33:15 -0800 | |
|---|---|---|
| committer | 2020-03-22 15:54:41 -0700 | |
| commit | cc5753e48d5ed5c3f2b73f8a724ab34b446cb5ef (patch) | |
| tree | 70880185ffcb24fca01c3f58cfe7aa9a97ba354a | |
| parent | HelpChannels: notify configured list of roles instead of helpers only (diff) | |
HelpChannels: handle potential notification exceptions locally
The notification feature is not critical for the functionality of the
help channel system. Therefore, the exception should not be allowed to
propagate and halt the system in some way.
| -rw-r--r-- | bot/cogs/help_channels.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index 28bbac790..45509e1c7 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -460,7 +460,10 @@ class HelpChannels(Scheduler, commands.Cog): else: should_send = True - if should_send: + if not should_send: + return + + try: channel = self.bot.get_channel(constants.HelpChannels.notify_channel) mentions = " ".join(f"<@&{role}>" for role in constants.HelpChannels.notify_roles) @@ -469,6 +472,9 @@ class HelpChannels(Scheduler, commands.Cog): f"are no more dormant ones. Consider freeing up some in-use channels manually by " f"using the `!dormant` command within the channels." ) + except Exception: + # Handle it here cause this feature isn't critical for the functionality of the system. + log.exception("Failed to send notification about lack of dormant channels!") @commands.Cog.listener() async def on_message(self, message: discord.Message) -> None: |