@@ -88,7 +88,7 @@ const titleSetCooldown = 5 * 60 * 1000;
88
88
export class HelpThreadModule extends Module {
89
89
@listener ( { event : 'messageCreate' } )
90
90
async onNewQuestion ( msg : Message ) {
91
- if ( ! this . isHelpChannel ( msg . channel ) ) return ;
91
+ if ( ! isHelpChannel ( msg . channel ) ) return ;
92
92
if ( msg . author . id === this . client . user ! . id ) return ;
93
93
this . updateHelpInfo ( msg . channel ) ;
94
94
let thread = await msg . startThread ( {
@@ -108,7 +108,7 @@ export class HelpThreadModule extends Module {
108
108
@listener ( { event : 'threadUpdate' } )
109
109
async onThreadExpire ( thread : ThreadChannel ) {
110
110
if (
111
- ! this . isHelpThread ( thread ) ||
111
+ ! isHelpThread ( thread ) ||
112
112
! ( ( await thread . fetch ( ) ) as ThreadChannel ) . archived ||
113
113
this . manuallyArchivedThreads . delete ( thread . id )
114
114
)
@@ -123,7 +123,7 @@ export class HelpThreadModule extends Module {
123
123
description : 'Help System: Close an active help thread' ,
124
124
} )
125
125
async close ( msg : Message ) {
126
- if ( ! this . isHelpThread ( msg . channel ) )
126
+ if ( ! isHelpThread ( msg . channel ) )
127
127
return await sendWithMessageOwnership (
128
128
msg ,
129
129
':warning: This can only be run in a help thread' ,
@@ -168,38 +168,16 @@ export class HelpThreadModule extends Module {
168
168
169
169
@listener ( { event : 'messageCreate' } )
170
170
deletePinMessage ( msg : Message ) {
171
- if (
172
- this . isHelpChannel ( msg . channel ) &&
173
- msg . type === 'CHANNEL_PINNED_MESSAGE'
174
- )
171
+ if ( isHelpChannel ( msg . channel ) && msg . type === 'CHANNEL_PINNED_MESSAGE' )
175
172
msg . delete ( ) ;
176
173
}
177
174
178
- private isHelpChannel (
179
- channel : Omit < Channel , 'partial' > ,
180
- ) : channel is TextChannel {
181
- return (
182
- channel instanceof TextChannel &&
183
- channel . parentId == helpCategory &&
184
- channel . id !== howToGetHelpChannel
185
- ) ;
186
- }
187
-
188
- private isHelpThread (
189
- channel : Omit < Channel , 'partial' > ,
190
- ) : channel is ThreadChannel & { parent : TextChannel } {
191
- return (
192
- channel instanceof ThreadChannel &&
193
- this . isHelpChannel ( channel . parent ! )
194
- ) ;
195
- }
196
-
197
175
@command ( {
198
176
description : 'Help System: Ping the @Helper role from a help thread' ,
199
177
aliases : [ 'helpers' ] ,
200
178
} )
201
179
async helper ( msg : Message ) {
202
- if ( ! this . isHelpThread ( msg . channel ) ) {
180
+ if ( ! isHelpThread ( msg . channel ) ) {
203
181
return sendWithMessageOwnership (
204
182
msg ,
205
183
':warning: You may only ping helpers from a help thread' ,
@@ -249,7 +227,7 @@ export class HelpThreadModule extends Module {
249
227
250
228
@command ( { single : true , description : 'Help System: Rename a help thread' } )
251
229
async title ( msg : Message , title : string ) {
252
- if ( ! this . isHelpThread ( msg . channel ) )
230
+ if ( ! isHelpThread ( msg . channel ) )
253
231
return sendWithMessageOwnership (
254
232
msg ,
255
233
':warning: This can only be run in a help thread' ,
@@ -296,3 +274,19 @@ export class HelpThreadModule extends Module {
296
274
msg . channel . send ( { embeds : howToGetHelpEmbeds ( ) } ) ;
297
275
}
298
276
}
277
+
278
+ export function isHelpChannel (
279
+ channel : Omit < Channel , 'partial' > ,
280
+ ) : channel is TextChannel {
281
+ return (
282
+ channel instanceof TextChannel &&
283
+ channel . parentId == helpCategory &&
284
+ channel . id !== howToGetHelpChannel
285
+ ) ;
286
+ }
287
+
288
+ export function isHelpThread (
289
+ channel : Omit < Channel , 'partial' > ,
290
+ ) : channel is ThreadChannel & { parent : TextChannel } {
291
+ return channel instanceof ThreadChannel && isHelpChannel ( channel . parent ! ) ;
292
+ }
0 commit comments