From 3bedc21d056acbdaeccce9542d78be3fd3c01d1c Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:43:41 -0800 Subject: [PATCH] fix bulk deletions in deleteMessages --- src/server/lib/DiscordAPI/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/lib/DiscordAPI/index.ts b/src/server/lib/DiscordAPI/index.ts index cccfe0c..bcb5bd8 100644 --- a/src/server/lib/DiscordAPI/index.ts +++ b/src/server/lib/DiscordAPI/index.ts @@ -58,7 +58,7 @@ export class Client { // Remove bulk deletable messages - let bulkDeletable = ids.filter(e => convertSnowflakeToDate(e).valueOf() < 2 * 7 * 24 * 60 * 60 * 1000) + let bulkDeletable = ids.filter(e => Date.now()-convertSnowflakeToDate(e).valueOf() < 2 * 7 * 24 * 60 * 60 * 1000) await this.rest.fetch(`/channels/${this.targetChannel}/messages/bulk-delete`, { method: "POST", body: JSON.stringify({messages: bulkDeletable}) @@ -69,7 +69,7 @@ export class Client { // there's probably a better way to do this @Jack5079 // fix for me if possible await Promise.all(ids.map(async e => { - if (convertSnowflakeToDate(e).valueOf() >= 2 * 7 * 24 * 60 * 60 * 1000) { + if (Date.now()-convertSnowflakeToDate(e).valueOf() >= 2 * 7 * 24 * 60 * 60 * 1000) { return await this.deleteMessage(e) } }).filter(Boolean)) // filter based on whether or not it's undefined