3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Fix !clean sometimes cleaning too many messages

This commit is contained in:
Dragory 2019-10-14 01:10:32 +03:00
parent 9ec93db08c
commit 94756faa5d

View file

@ -618,8 +618,10 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
if (moment.utc(message.posted_at).valueOf() < timeCutoff) return false;
return true;
});
const remaining = args.count - messagesToClean.length;
const withoutOverflow = filtered.slice(0, remaining);
messagesToClean.push(...withoutOverflow);
messagesToClean.push(...filtered);
beforeId = potentialMessagesToClean[potentialMessagesToClean.length - 1].id;
if (moment.utc(potentialMessagesToClean[potentialMessagesToClean.length - 1].posted_at).valueOf() < timeCutoff) {