From 71b143d7da6d2af79ffaa190577e3946fba18d46 Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:38:17 +1100 Subject: [PATCH] Lock and archive the old threads --- src/config.json | 3 ++- src/index.ts | 13 +++++++++++++ src/interfaces.d.ts | 5 +++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/config.json b/src/config.json index 9a5a74d..43c93ee 100644 --- a/src/config.json +++ b/src/config.json @@ -85,7 +85,8 @@ "dcmod_chat": "742324777934520350", "mpmod_chat": "516344221452599306", "multifarm_chat": "1149238561934151690", - "pw_list": "1193424588554645505" + "pw_list": "1193424588554645505", + "help_forum": "1022236553562558464" } } } diff --git a/src/index.ts b/src/index.ts index 6ec8e78..8e5b341 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,6 +25,19 @@ client.on('error', (error: Error)=>_(error, 'clientError')); // Interval timers for modules setInterval(async()=>await MPModule(client), refreshTimerSecs); setInterval(()=>YTModule(client), 180000); // 3 minutes +setInterval(async()=>{ + const forum = client.guilds.cache.get(client.config.dcServer.id).channels.cache.get(client.config.dcServer.channels.help_forum) as Discord.ForumChannel; + await forum.threads.fetch(); + + for await (const thread of forum.threads.cache.values()) { + await thread.messages.fetch(); + if (thread.lastMessage.createdTimestamp <= Date.now() - 1555200000) {// check if thread is inactive for over 18 days + await thread.setLocked(true).catch(()=>null); + await thread.setArchived(true, 'Inactive for over 18 days').catch(()=>null); + Logger.console('log', 'ThreadTimer', `${thread.name} has been archived and locked due to inactivity`); + } + } +}, 1200000); // 20 minutes // Event loop for punishments and daily msgs setInterval(async()=>{ diff --git a/src/interfaces.d.ts b/src/interfaces.d.ts index 0d2a23f..45210e6 100644 --- a/src/interfaces.d.ts +++ b/src/interfaces.d.ts @@ -159,8 +159,9 @@ export interface Config { punishment_log: string, dcmod_chat: string, mpmod_chat: string, - multifarm_chat: string - pw_list: string + multifarm_chat: string, + pw_list: string, + help_forum: string } } }