aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Senjan21 <[email protected]>2020-07-16 10:41:54 +0200
committerGravatar Senjan21 <[email protected]>2020-07-16 10:41:54 +0200
commitb6abe9cbb2e63f562bb44e14d51ea87f19da32ac (patch)
tree29a149436ea2321697968bf123fc9b13026c1c76
parentFix docstring and comments (diff)
Prevent deleting messages above the desired message.
-rw-r--r--bot/cogs/clean.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/bot/cogs/clean.py b/bot/cogs/clean.py
index aee7fa055..f436e531a 100644
--- a/bot/cogs/clean.py
+++ b/bot/cogs/clean.py
@@ -132,17 +132,18 @@ class Clean(Cog):
# If we are looking for specific message.
if until_message:
- # Since we will be using `delete_messages` method of a TextChannel and we need message objects to
- # use it as well as to send logs we will start appending messages here instead adding them from
- # purge.
- messages.append(message)
+
# we could use ID's here however in case if the message we are looking for gets deleted,
# we won't have a way to figure that out thus checking for datetime should be more reliable
- if message.created_at <= until_message.created_at:
+ if message.created_at < until_message.created_at:
# means we have found the message until which we were supposed to be deleting.
- message_ids.append(message.id)
break
+ # Since we will be using `delete_messages` method of a TextChannel and we need message objects to
+ # use it as well as to send logs we will start appending messages here instead adding them from
+ # purge.
+ messages.append(message)
+
# If the message passes predicate, let's save it.
if predicate is None or predicate(message):
message_ids.append(message.id)