diff options
author | 2020-05-29 19:56:40 +0200 | |
---|---|---|
committer | 2020-05-29 20:02:41 +0200 | |
commit | 63f5028641e9b78c61d3bcfe3bbaa6f80c8a288a (patch) | |
tree | f043b32e058e1f08b57864ade4dfce6030cdb945 | |
parent | Merge pull request #947 from python-discord/redis_persistence (diff) |
Fix `check_for_answer` breaking on missing cache
The `check_for_answer` method of the HelpChannels cog relies on the
channel->claimant cache being available. However, as this cache is
(currently) lost during bot restarts, this method may fail with a
KeyError exception.
I've used `dict.get` with an `if not claimant: return` to circumvent
this issue.
-rw-r--r-- | bot/cogs/help_channels.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index d2a55fba6..2221132d4 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -660,10 +660,13 @@ class HelpChannels(Scheduler, commands.Cog): # Check if there is an entry in unanswered (does not persist across restarts) if channel.id in self.unanswered: - claimant_id = self.help_channel_claimants[channel].id + claimant = self.help_channel_claimants.get(channel) + if not claimant: + # The mapping for this channel was lost, we can't do anything. + return # Check the message did not come from the claimant - if claimant_id != message.author.id: + if claimant.id != message.author.id: # Mark the channel as answered self.unanswered[channel.id] = False |