From 9e39233405283bcf35dd952203de4f3c9ef8ac73 Mon Sep 17 00:00:00 2001 From: Minzkraut Date: Sun, 7 Jan 2024 23:42:43 +0100 Subject: [PATCH] Cleanup #spam after 48 hours --- ...eanupMessages.js => cleanupMessages-RP.js} | 0 timers/cleanupMessages-Spam.js | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+) rename timers/{cleanupMessages.js => cleanupMessages-RP.js} (100%) create mode 100644 timers/cleanupMessages-Spam.js diff --git a/timers/cleanupMessages.js b/timers/cleanupMessages-RP.js similarity index 100% rename from timers/cleanupMessages.js rename to timers/cleanupMessages-RP.js diff --git a/timers/cleanupMessages-Spam.js b/timers/cleanupMessages-Spam.js new file mode 100644 index 0000000..27ffbd3 --- /dev/null +++ b/timers/cleanupMessages-Spam.js @@ -0,0 +1,24 @@ +module.exports = { + timeout: 60000, + immediate: true, + name: 'Cleanup tasks', + async tick(client, timer) { + const channelId = '1111054421091155978'; + const channel = await client.channels.fetch(channelId); + + console.log(`[TIMER] Running cleanup task for ${channel.guild.name}/${channel.name}`); + channel.messages.fetch({ limit: 100 }).then(messages => { + //Iterate through the messages here with the variable "messages". + messages.forEach(message => { + let ageInMinutes = Math.ceil((Date.now() - message.createdTimestamp) / 1000 / 60); + if(ageInMinutes < 2880) { + //Skip messages posted within last 48 Hours + return; + } + + console.log(`[CLEANUP] [${message.guild.name}/${message.channel.name}] | ${message.author.globalName}: ${message.content}`); + message.delete(); + }); + }); + }, +}; \ No newline at end of file