aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris <[email protected]>2021-04-14 16:54:27 +0100
committerGravatar Chris <[email protected]>2021-04-14 16:54:27 +0100
commit347927cc6d86e852959db716b6de31c6a886640d (patch)
tree6ee5c26e3b68f8bbe87dde7005d4304f581f3280
parentMerge pull request #1521 from ToxicKidz/dont-use-startswith (diff)
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.
-rw-r--r--bot/exts/utils/clean.py8
1 files 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 = []