From 53f8ea442994a8f5a465d49031894be0ae17748a Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Mon, 2 Aug 2021 20:11:17 -0700 Subject: 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 --- bot/utils/messages.py | 13 ++++++++----- 1 file 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( -- cgit v1.2.3