From a175bdc1c79b59628b88e6fd243bb8bacdb27074 Mon Sep 17 00:00:00 2001 From: Michael H Date: Mon, 25 Jun 2018 07:45:43 -0400 Subject: [PATCH] [V3 Cleanup] Fix cleaning up too many messages (#1864) Resolves #1863 --- redbot/cogs/cleanup/cleanup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/cleanup/cleanup.py b/redbot/cogs/cleanup/cleanup.py index b202409e8..af8c3b584 100644 --- a/redbot/cogs/cleanup/cleanup.py +++ b/redbot/cogs/cleanup/cleanup.py @@ -71,11 +71,11 @@ class Cleanup: to_delete = [] too_old = False - while not too_old and len(to_delete) - 1 < number: + while not too_old and len(to_delete) < number: message = None async for message in channel.history(limit=limit, before=before, after=after): if ( - (not number or len(to_delete) - 1 < number) + (not number or len(to_delete) < number) and check(message) and (ctx.message.created_at - message.created_at).days < 14 and (delete_pinned or not message.pinned)