From 91e6e41377d1e76462478de21bdafcecd229def7 Mon Sep 17 00:00:00 2001 From: Erik Zuuring Date: Thu, 12 Dec 2024 10:30:00 +0200 Subject: [PATCH 1/3] Re-enable `setAutoArchiveDuration` ### Notes Let's re-enable the `setAutoArchiveDuration` to 24 hours / `OneDay` after the initial warning message is sent. --- discord-scripts/thread-management/check-thread-archiving.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/discord-scripts/thread-management/check-thread-archiving.ts b/discord-scripts/thread-management/check-thread-archiving.ts index 16eeff62..d6e562c0 100644 --- a/discord-scripts/thread-management/check-thread-archiving.ts +++ b/discord-scripts/thread-management/check-thread-archiving.ts @@ -37,7 +37,7 @@ const THREAD_CHECK_CADENCE = 12 * HOUR // 12 * HOUR // Use a ThreadAutoArchiveDuration as we'll still lean on Discord to // auto-archive after issuing the warning, so we want the value to be // one that we can update auto-archiving to. -// const AUTO_ARCHIVE_WARNING_LEAD_MINUTES: ThreadAutoArchiveDuration = ThreadAutoArchiveDuration.OneDay +const AUTO_ARCHIVE_WARNING_LEAD_MINUTES: ThreadAutoArchiveDuration = ThreadAutoArchiveDuration.OneDay /** * A helper to request follow-up action on a thread based on the id of the user @@ -474,7 +474,8 @@ async function checkThreadStatus( }, ], }) - + // Let's add back setting the thread autoArchive to 24hr after the message is sent + await thread.setAutoArchiveDuration(AUTO_ARCHIVE_WARNING_LEAD_MINUTES) // Use robot brain to store the warning event data robot.brain.set(warningKey, warningMessage.id) robot.logger.info( From 84b76e0a3a2819681c4ed68e263388098d627372 Mon Sep 17 00:00:00 2001 From: Erik Zuuring Date: Thu, 12 Dec 2024 10:40:35 +0200 Subject: [PATCH 2/3] Linter fix --- discord-scripts/thread-management/check-thread-archiving.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/discord-scripts/thread-management/check-thread-archiving.ts b/discord-scripts/thread-management/check-thread-archiving.ts index d6e562c0..762c3c63 100644 --- a/discord-scripts/thread-management/check-thread-archiving.ts +++ b/discord-scripts/thread-management/check-thread-archiving.ts @@ -37,7 +37,8 @@ const THREAD_CHECK_CADENCE = 12 * HOUR // 12 * HOUR // Use a ThreadAutoArchiveDuration as we'll still lean on Discord to // auto-archive after issuing the warning, so we want the value to be // one that we can update auto-archiving to. -const AUTO_ARCHIVE_WARNING_LEAD_MINUTES: ThreadAutoArchiveDuration = ThreadAutoArchiveDuration.OneDay +const AUTO_ARCHIVE_WARNING_LEAD_MINUTES: ThreadAutoArchiveDuration = + ThreadAutoArchiveDuration.OneDay /** * A helper to request follow-up action on a thread based on the id of the user From 38a03b45c6fdf7ff24749568d97da32c4c3d66a2 Mon Sep 17 00:00:00 2001 From: Erik Zuuring Date: Mon, 16 Dec 2024 14:01:49 +0200 Subject: [PATCH 3/3] Add weekend ignore This checks whether it's `isWeekend` before running the thread status, if it is we return. --- .../thread-management/check-thread-archiving.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/discord-scripts/thread-management/check-thread-archiving.ts b/discord-scripts/thread-management/check-thread-archiving.ts index 762c3c63..a4befc7f 100644 --- a/discord-scripts/thread-management/check-thread-archiving.ts +++ b/discord-scripts/thread-management/check-thread-archiving.ts @@ -40,6 +40,9 @@ const THREAD_CHECK_CADENCE = 12 * HOUR // 12 * HOUR const AUTO_ARCHIVE_WARNING_LEAD_MINUTES: ThreadAutoArchiveDuration = ThreadAutoArchiveDuration.OneDay +// Let's grab if it's the weekend, 0 = sunday, 6 = saturday +const isWeekend = (): boolean => [0, 6].includes(new Date().getDay()) + /** * A helper to request follow-up action on a thread based on the id of the user * who will follow up and the initial requester of follow-up action. @@ -370,6 +373,11 @@ async function checkThreadStatus( robot: Robot, discordClient: Client, ): Promise { + if (isWeekend()) { + robot.logger.info("Skipping thread status checks on the weekend.") + return + } + const threadMetadataByThreadId = getAllThreadMetadata(robot.brain) Object.entries(threadMetadataByThreadId)