@@ -2,13 +2,13 @@ import type { Client } from 'discord.js'
2
2
import { CronJob } from 'cron'
3
3
import { createDefaultEmbed } from '@/utils'
4
4
5
- export function startThreadCheckCron ( client : Client ) {
5
+ export function startThreadStaleCheckCron ( client : Client ) {
6
6
const debug = process . env . CRON_DEBUG_MODE === '1'
7
7
8
8
const job = new CronJob (
9
9
debug ? '*/10 * * * * *' : '0 * * * *' , // run every hour on prod, every 10 sec on debug
10
10
async function ( ) {
11
- console . log ( '[Cron] Checking inactive threads...' )
11
+ console . log ( '[Cron][ThreadStaleCheck] Checking inactive threads...' )
12
12
13
13
for ( const [ , guild ] of client . guilds . cache ) {
14
14
try {
@@ -19,7 +19,18 @@ export function startThreadCheckCron(client: Client) {
19
19
if ( thread . parentId !== process . env . COMMUNITY_SUPPORT_FORUM_ID ) continue
20
20
// Ignore threads that are pinned
21
21
if ( thread . flags . has ( 'Pinned' ) ) {
22
- debug && console . log ( `[Debug][Cron] Skipping thread ${ thread . id } is pinned` )
22
+ debug &&
23
+ console . log (
24
+ `[Debug][Cron][ThreadStaleCheck] Skipping thread ${ thread . id } is pinned` ,
25
+ )
26
+ continue
27
+ }
28
+ // Ignore threads that are already solved
29
+ if ( thread . appliedTags . includes ( process . env . COMMUNITY_SUPPORT_FORUM_SOLVED_TAG_ID ! ) ) {
30
+ debug &&
31
+ console . log (
32
+ `[Debug][Cron][ThreadStaleCheck] Skipping thread ${ thread . id } is solved` ,
33
+ )
23
34
continue
24
35
}
25
36
@@ -36,7 +47,9 @@ export function startThreadCheckCron(client: Client) {
36
47
37
48
if ( inactiveFor > archiveThreshold ) {
38
49
debug &&
39
- console . log ( `[Debug][Cron] Marking inactive thread as solved: ${ thread . name } ` )
50
+ console . log (
51
+ `[Debug][Cron][ThreadStaleCheck] Marking inactive thread as solved: ${ thread . name } ` ,
52
+ )
40
53
41
54
const embed = createDefaultEmbed ( {
42
55
title : ':white_check_mark: Thread archived' ,
0 commit comments