File tree 1 file changed +19
-3
lines changed
discord-scripts/thread-management
1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -389,10 +389,26 @@ async function checkThreadStatus(
389
389
390
390
// We can then archive the thread if the expiry time has been reached or passed
391
391
if ( autoArchiveTime - currentTime <= 0 ) {
392
+ const warningKey = `thread-warning:${ threadId } `
393
+ const warningMessageId = robot . brain . get ( warningKey )
394
+
395
+ if ( warningMessageId ) {
396
+ try {
397
+ const warningMessage = await thread . messages . fetch ( warningMessageId )
398
+ // this will edit the original message to indicate the thread has been archived
399
+ await warningMessage . edit ( {
400
+ content :
401
+ "This thread is now archived as the auto-archive duration has been reached." ,
402
+ components : [ ] ,
403
+ } )
404
+ } catch ( error ) {
405
+ robot . logger . error (
406
+ `Failed to edit the warning message for thread ${ threadId } : ${ error } ` ,
407
+ )
408
+ }
409
+ }
410
+
392
411
await thread . setArchived ( true )
393
- await thread . send (
394
- "This thread is now archived as the auto-archive duration has been reached." ,
395
- )
396
412
robot . logger . info (
397
413
`Archived thread ${ threadId } as the auto-archive time has been reached.` ,
398
414
)
You can’t perform that action at this time.
0 commit comments