diff options
author | 2022-02-23 07:30:28 -0500 | |
---|---|---|
committer | 2022-02-23 07:30:28 -0500 | |
commit | 9044f5404ed2be1b5eb4160f6d2a86e329f6abf5 (patch) | |
tree | f11bb1edb4434f21563e24dfb17e15d22ee5e8c1 | |
parent | Merge pull request #2078 from python-discord/chris/fix/help-channel-errors (diff) |
fix: Make sure the regex match is not None before adding to claimaints cache
If there was a bot message in a help channel that contained an embed that was not the claimed channel message, this would raise an attribute error.
-rw-r--r-- | bot/exts/help_channels/_channel.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index ff9e6a347..ea7d972b5 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -182,9 +182,10 @@ async def ensure_cached_claimant(channel: discord.TextChannel) -> None: if _message._match_bot_embed(message, _message.DORMANT_MSG): log.info("Hit the dormant message embed before finding a claimant in %s (%d).", channel, channel.id) break - user_id = CLAIMED_BY_RE.match(message.embeds[0].description).group("user_id") - await _caches.claimants.set(channel.id, int(user_id)) - return + # Only set the claimant if the first embed matches the claimed channel embed regex + if match := CLAIMED_BY_RE.match(message.embeds[0].description): + await _caches.claimants.set(channel.id, int(match.group("user_id"))) + return await bot.instance.get_channel(constants.Channels.helpers).send( f"I couldn't find a claimant for {channel.mention} in that last 1000 messages. " |