diff --git a/discord-scripts/thread-management/check-thread-archiving.ts b/discord-scripts/thread-management/check-thread-archiving.ts index 16eeff62..a4befc7f 100644 --- a/discord-scripts/thread-management/check-thread-archiving.ts +++ b/discord-scripts/thread-management/check-thread-archiving.ts @@ -37,7 +37,11 @@ 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 + +// 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 @@ -369,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) @@ -474,7 +483,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(