From 347927cc6d86e852959db716b6de31c6a886640d Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 14 Apr 2021 16:54:27 +0100 Subject: Catch NotFound errors when trying to delete the invocation message when cleaning This often happens during a raid, when an int e script is added to ban & clean messages. Since the invocation message will be deleted on the first run, we should except subsequent NotFound errors. --- bot/exts/utils/clean.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bot/exts/utils/clean.py b/bot/exts/utils/clean.py index 8acaf9131..cb662e852 100644 --- a/bot/exts/utils/clean.py +++ b/bot/exts/utils/clean.py @@ -3,7 +3,7 @@ import random import re from typing import Iterable, Optional -from discord import Colour, Embed, Message, TextChannel, User +from discord import Colour, Embed, Message, TextChannel, User, errors from discord.ext import commands from discord.ext.commands import Cog, Context, group, has_any_role @@ -115,7 +115,11 @@ class Clean(Cog): # Delete the invocation first self.mod_log.ignore(Event.message_delete, ctx.message.id) - await ctx.message.delete() + try: + await ctx.message.delete() + except errors.NotFound: + # Invocation message has already been deleted + log.info("Tried to delete invocation message, but it was already deleted.") messages = [] message_ids = [] -- cgit v1.2.3