@@ -29,6 +29,15 @@ Consider rephrasing the question to maximize your chance of getting a good answe
29
29
If you're not sure how, have a look through [StackOverflow's guide on asking a good question](https://stackoverflow.com/help/how-to-ask).
30
30
` ) ;
31
31
32
+ const helperCloseEmbed = ( member : GuildMember ) =>
33
+ new MessageEmbed ( ) . setColor ( BLOCKQUOTE_GREY ) . setDescription ( `
34
+ Because your issue seemed to be resolved, this thread was closed by ${ member } .
35
+
36
+ If your issue is not resolved, **you can post another message here and the thread will automatically re-open**.
37
+
38
+ *If you have a different question, just ask in <#${ generalHelpChannel } >.*
39
+ ` ) ;
40
+
32
41
// A zero-width space (necessary to prevent discord from trimming the leading whitespace), followed by a three non-breaking spaces.
33
42
const indent = '\u200b\u00a0\u00a0\u00a0' ;
34
43
@@ -92,7 +101,7 @@ export class HelpThreadModule extends Module {
92
101
@listener ( { event : 'messageCreate' } )
93
102
async onNewQuestion ( msg : Message ) {
94
103
if ( ! isHelpChannel ( msg . channel ) ) return ;
95
- if ( msg . author . id === this . client . user ! . id ) return ;
104
+ if ( msg . author . bot ) return ;
96
105
console . log (
97
106
'Received new question from' ,
98
107
msg . author ,
@@ -142,8 +151,12 @@ export class HelpThreadModule extends Module {
142
151
this . manuallyArchivedThreads . delete ( thread . id )
143
152
)
144
153
return ;
154
+ const threadData = ( await HelpThread . findOne ( thread . id ) ) ! ;
145
155
console . log ( `Help thread expired:` , thread ) ;
146
- await thread . send ( { embeds : [ threadExpireEmbed ] } ) ;
156
+ await thread . send ( {
157
+ content : `<@${ threadData . ownerId } >` ,
158
+ embeds : [ threadExpireEmbed ] ,
159
+ } ) ;
147
160
this . manuallyArchivedThreads . add ( thread . id ) ;
148
161
await this . archiveThread ( thread ) ;
149
162
}
@@ -162,12 +175,20 @@ export class HelpThreadModule extends Module {
162
175
let thread : ThreadChannel = msg . channel ;
163
176
const threadData = ( await HelpThread . findOne ( thread . id ) ) ! ;
164
177
178
+ const isOwner = threadData . ownerId === msg . author . id ;
179
+
165
180
if (
166
- threadData . ownerId === msg . author . id ||
181
+ isOwner ||
182
+ msg . member ?. roles . cache . has ( trustedRoleId ) ||
167
183
msg . member ?. permissions . has ( 'MANAGE_MESSAGES' )
168
184
) {
169
185
console . log ( `Closing help thread:` , thread ) ;
170
186
await msg . react ( '✅' ) ;
187
+ if ( ! isOwner )
188
+ await msg . channel . send ( {
189
+ content : `<@${ threadData . ownerId } >` ,
190
+ embeds : [ helperCloseEmbed ( msg . member ! ) ] ,
191
+ } ) ;
171
192
this . manuallyArchivedThreads . add ( thread . id ) ;
172
193
await this . archiveThread ( thread ) ;
173
194
} else {
0 commit comments