aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2021-04-14 17:57:50 +0200
committerGravatar GitHub <[email protected]>2021-04-14 17:57:50 +0200
commit3d9df77be3a2676a84ab3400fd31f907011cb3a7 (patch)
tree6ee5c26e3b68f8bbe87dde7005d4304f581f3280
parentMerge pull request #1521 from ToxicKidz/dont-use-startswith (diff)
parentCatch NotFound errors when trying to delete the invocation message when cleaning (diff)
Merge pull request #1525 from python-discord/catch-invocation-not-found-error
Catch NotFound errors when trying to delete the invocation message when cleaning
-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 = []