aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2021-08-02 20:11:17 -0700
committerGravatar MarkKoz <[email protected]>2021-08-02 20:27:18 -0700
commit53f8ea442994a8f5a465d49031894be0ae17748a (patch)
treea86e2cbf1f52e95103b2215a12b25221d68925d8
parentMerge pull request #1704 from python-discord/whitelist-pydis-partners (diff)
Catch 404 error when waiting to delete message
Sometimes the message is deleted before the function gets around to it. Fixes BOT-1JD Fixes BOT-1K3 Fixes BOT-1JE
-rw-r--r--bot/utils/messages.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/bot/utils/messages.py b/bot/utils/messages.py
index 90672fba2..a82096b1c 100644
--- a/bot/utils/messages.py
+++ b/bot/utils/messages.py
@@ -97,11 +97,14 @@ async def wait_for_deletion(
)
try:
- await bot.instance.wait_for('reaction_add', check=check, timeout=timeout)
- except asyncio.TimeoutError:
- await message.clear_reactions()
- else:
- await message.delete()
+ try:
+ await bot.instance.wait_for('reaction_add', check=check, timeout=timeout)
+ except asyncio.TimeoutError:
+ await message.clear_reactions()
+ else:
+ await message.delete()
+ except discord.NotFound:
+ log.trace(f"wait_for_deletion: message {message.id} deleted prematurely.")
async def send_attachments(