File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ export class HelpChanModule extends Module {
67
67
. setDescription ( DORMANT_MESSAGE ) ;
68
68
69
69
busyChannels : Set < string > = new Set ( ) ; // a lock to eliminate race conditions
70
- ongoingEmptyTimeouts : Set < string > = new Set ( ) ; // a lock used to prevent multiple timeouts running on the same channel
70
+ ongoingEmptyTimeouts : Map < string , NodeJS . Timeout > = new Map ( ) ; // a lock used to prevent multiple timeouts running on the same channel
71
71
72
72
private getChannelName ( guild : Guild ) {
73
73
const takenChannelNames = guild . channels . cache
@@ -118,17 +118,18 @@ export class HelpChanModule extends Module {
118
118
}
119
119
120
120
async startEmptyTimeout ( channel : TextChannel ) {
121
- if ( this . ongoingEmptyTimeouts . has ( channel . id ) ) return ;
121
+ const existingTimeout = this . ongoingEmptyTimeouts . get ( channel . id ) ;
122
+ if ( existingTimeout ) clearTimeout ( existingTimeout ) ;
122
123
123
- this . ongoingEmptyTimeouts . add ( channel . id ) ;
124
-
125
- setTimeout ( async ( ) => {
124
+ const timeout = setTimeout ( async ( ) => {
126
125
this . ongoingEmptyTimeouts . delete ( channel . id ) ;
127
126
128
127
if ( await this . checkEmptyOngoing ( channel ) ) {
129
128
await this . markChannelAsDormant ( channel ) ;
130
129
}
131
130
} , ongoingEmptyTimeout ) ;
131
+
132
+ this . ongoingEmptyTimeouts . set ( channel . id , timeout ) ;
132
133
}
133
134
134
135
@listener ( { event : 'messageDelete' } )
You can’t perform that action at this time.
0 commit comments