aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo <[email protected]>2020-02-18 18:00:09 +0100
committerGravatar Matteo <[email protected]>2020-02-18 18:00:09 +0100
commite1e68ad561513cc02eac0eab59990430fbcfe516 (patch)
tree2c4f6cc163d0adeb67c2e267a5ec7672680b5005
parentUse pregenerated partials (diff)
Suppress HTTPException while deleting bot output
It was triggering an error if the user deleted the output before re-evaluating
-rw-r--r--bot/cogs/snekbox.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index d075c4fd5..42830fb58 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -1,4 +1,5 @@
import asyncio
+import contextlib
import datetime
import logging
import re
@@ -7,7 +8,7 @@ from functools import partial
from signal import Signals
from typing import Optional, Tuple
-from discord import Message, Reaction, User
+from discord import HTTPException, Message, Reaction, User
from discord.ext.commands import Cog, Context, command, guild_only
from bot.bot import Bot
@@ -250,7 +251,8 @@ class Snekbox(Cog):
log.info(f"Re-evaluating message {ctx.message.id}")
code = new_message.content.split(' ', maxsplit=1)[1]
await ctx.message.clear_reactions()
- await response.delete()
+ with contextlib.suppress(HTTPException):
+ await response.delete()
except asyncio.TimeoutError:
await ctx.message.clear_reactions()
return