diff options
author | 2022-02-09 10:38:13 +0000 | |
---|---|---|
committer | 2022-02-20 20:28:23 +0000 | |
commit | 33203cbfe95f28501af28a42e0c49f4d42b6f021 (patch) | |
tree | db0d20fad84f7618bb7c6213c3470791afddae7f | |
parent | Remove discord formatted timestamp from log message (#2100) (diff) |
Cancel help channel claim on 500 from Discord
If we get a 500 error from Discord when trying to move the help channel to in use, attempt to let the user know, then cancel the claim.
-rw-r--r-- | bot/exts/help_channels/_cog.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 541c791e5..6d061c8ca 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -111,14 +111,31 @@ class HelpChannels(commands.Cog): """ log.info(f"Channel #{message.channel} was claimed by `{message.author.id}`.") + try: + await self.move_to_in_use(message.channel) + except discord.DiscordServerError: + try: + await message.channel.send( + "The bot encountered a Discord API error while trying to move this channel, please try again later." + ) + except Exception as e: + log.warning("Error occurred while sending fail claim message:", exc_info=e) + log.info( + "500 error from Discord when moving #%s (%d) to in-use for %s (%d). Cancelling claim.", + message.channel.name, + message.channel.id, + message.author.name, + message.author.id, + ) + self.bot.stats.incr("help.failed_claims.500_on_move") + return + embed = discord.Embed( description=f"Channel claimed by {message.author.mention}.", color=constants.Colours.bright_green, ) await message.channel.send(embed=embed) - await self.move_to_in_use(message.channel) - # Handle odd edge case of `message.author` not being a `discord.Member` (see bot#1839) if not isinstance(message.author, discord.Member): log.debug(f"{message.author} ({message.author.id}) isn't a member. Not giving cooldown role or sending DM.") |