@@ -17,6 +17,8 @@ import {
17
17
BLOCKQUOTE_GREY ,
18
18
generalHelpChannel ,
19
19
howToGetHelpChannel ,
20
+ howToGiveHelpChannel ,
21
+ rolesChannelId ,
20
22
} from '../env' ;
21
23
import { isTrustedMember } from '../util/inhibitors' ;
22
24
import { sendWithMessageOwnership } from '../util/send' ;
@@ -38,9 +40,6 @@ If your issue is not resolved, **you can post another message here and the threa
38
40
*If you have a different question, just ask in <#${ generalHelpChannel } >.*
39
41
` ) ;
40
42
41
- // A zero-width space (necessary to prevent discord from trimming the leading whitespace), followed by a three non-breaking spaces.
42
- const indent = '\u200b\u00a0\u00a0\u00a0' ;
43
-
44
43
const closedEmoji = '☑️' ;
45
44
46
45
const helpInfo = ( channel : TextChannel ) =>
@@ -53,29 +52,29 @@ const howToGetHelpEmbeds = () => [
53
52
. setColor ( GREEN )
54
53
. setTitle ( 'How To Get Help' )
55
54
. setDescription (
56
- `
57
- • Post your question to one of the channels in this category.
58
- ${ indent } • If you're not sure which channel is best, just post in <#${ generalHelpChannel } >.
59
- ${ indent } • It's always ok to just ask your question; you don't need permission.
60
- • Our bot will make a thread dedicated to answering your channel.
61
- • Someone will (hopefully!) come along and help you.
62
- • When your question is resolved, type \`!close\`.
63
- ` ,
55
+ listify ( `
56
+ - Post your question to one of the channels in this category.
57
+ - If you're not sure which channel is best, just post in <#${ generalHelpChannel } >.
58
+ - It's always ok to just ask your question; you don't need permission.
59
+ - Our bot will make a thread dedicated to answering your channel.
60
+ - Someone will (hopefully!) come along and help you.
61
+ - When your question is resolved, type \`!close\`.
62
+ ` ) ,
64
63
) ,
65
64
new MessageEmbed ( )
66
65
. setColor ( GREEN )
67
66
. setTitle ( 'How To Get *Better* Help' )
68
67
. setDescription (
69
- `
70
- • Explain what you want to happen and why…
71
- ${ indent } • …and what actually happens, and your best guess at why.
72
- • Include a short code sample and any error messages you got.
73
- ${ indent } • Text is better than screenshots. Start code blocks with ${ '\\`\\`\\`ts' } .
74
- • If possible, create a minimal reproduction in the **[TypeScript Playground](https://www.typescriptlang.org/play)**.
75
- ${ indent } • Send the full link in its own message; do not use a link shortener.
76
- • Run \`!title <brief description>\` to make your help thread easier to spot.
77
- • For more tips, check out StackOverflow's guide on **[asking good questions](https://stackoverflow.com/help/how-to-ask)**.
78
- ` ,
68
+ listify ( `
69
+ - Explain what you want to happen and why…
70
+ - …and what actually happens, and your best guess at why.
71
+ - Include a short code sample and any error messages you got.
72
+ - Text is better than screenshots. Start code blocks with ${ '\\`\\`\\`ts' } .
73
+ - If possible, create a minimal reproduction in the **[TypeScript Playground](https://www.typescriptlang.org/play)**.
74
+ - Send the full link in its own message; do not use a link shortener.
75
+ - Run \`!title <brief description>\` to make your help thread easier to spot.
76
+ - For more tips, check out StackOverflow's guide on **[asking good questions](https://stackoverflow.com/help/how-to-ask)**.
77
+ ` ) ,
79
78
) ,
80
79
new MessageEmbed ( )
81
80
. setColor ( GREEN )
@@ -88,6 +87,46 @@ If not, and if you have followed the bullets above, you can ping helpers by runn
88
87
) ,
89
88
] ;
90
89
90
+ const howToGiveHelpEmbeds = ( ) => [
91
+ new MessageEmbed ( )
92
+ . setColor ( GREEN )
93
+ . setTitle ( 'How To Give Help' )
94
+ . setDescription (
95
+ listify ( `
96
+ - There are a couple ways you can browse help threads:
97
+ - The channel sidebar on the left will list threads you have joined.
98
+ - You can scroll through the channel to see all recent questions.
99
+ - The bot will mark closed questions with ${ closedEmoji } .
100
+ - In the channel, you can click the *⌗*\u2004icon at the top right to view threads by title.
101
+
102
+ ` ) ,
103
+ ) ,
104
+ new MessageEmbed ( )
105
+ . setColor ( GREEN )
106
+ . setTitle ( 'How To Give *Better* Help' )
107
+ . setDescription (
108
+ listify ( `
109
+ - Get yourself the <@&${ trustedRoleId } > role at <#${ rolesChannelId } >
110
+ - (If you don't like the pings, you can disable role mentions for the server.)
111
+ - As a <@&${ trustedRoleId } >, you can:
112
+ - Run \`!title <brief description>\` to set/update the thread title.
113
+ - This will assist other helpers in finding the thread.
114
+ - Also, it means your help is more accessible to others in the future.
115
+ - If a thread appears to be resolved, run \`!close\` to close it.
116
+ - *Only do this if the asker has indicated that their question has been resolved.*
117
+ ` ) ,
118
+ ) ,
119
+ new MessageEmbed ( )
120
+ . setColor ( GREEN )
121
+ . setTitle ( 'Useful Snippets' )
122
+ . setDescription (
123
+ listify ( `
124
+ - \`!screenshot\` — for if an asker posts a screenshot of code
125
+ - \`!ask\` — for if an asker only posts "can I get help?"
126
+ ` ) ,
127
+ ) ,
128
+ ] ;
129
+
91
130
const helpThreadWelcomeMessage = ( owner : GuildMember ) => `
92
131
${ owner } This thread is for your question; type \`!title <brief description>\`. \
93
132
When it's resolved, please type \`!close\`. \
@@ -340,13 +379,18 @@ export class HelpThreadModule extends Module {
340
379
341
380
@command ( )
342
381
async htgh ( msg : Message ) {
382
+ if ( ! msg . member ?. permissions . has ( 'MANAGE_MESSAGES' ) ) return ;
343
383
if (
344
- msg . channel . id !== howToGetHelpChannel ||
345
- ! msg . member ?. permissions . has ( 'MANAGE_MESSAGES' )
384
+ msg . channel . id !== howToGetHelpChannel &&
385
+ msg . channel . id !== howToGiveHelpChannel
346
386
)
347
387
return ;
348
388
( await msg . channel . messages . fetch ( ) ) . forEach ( x => x . delete ( ) ) ;
349
- msg . channel . send ( { embeds : howToGetHelpEmbeds ( ) } ) ;
389
+ const embeds =
390
+ msg . channel . id === howToGetHelpChannel
391
+ ? howToGetHelpEmbeds ( )
392
+ : howToGiveHelpEmbeds ( ) ;
393
+ msg . channel . send ( { embeds } ) ;
350
394
}
351
395
}
352
396
@@ -356,7 +400,8 @@ export function isHelpChannel(
356
400
return (
357
401
channel instanceof TextChannel &&
358
402
channel . parentId == helpCategory &&
359
- channel . id !== howToGetHelpChannel
403
+ channel . id !== howToGetHelpChannel &&
404
+ channel . id !== howToGiveHelpChannel
360
405
) ;
361
406
}
362
407
@@ -365,3 +410,10 @@ export function isHelpThread(
365
410
) : channel is ThreadChannel & { parent : TextChannel } {
366
411
return channel instanceof ThreadChannel && isHelpChannel ( channel . parent ! ) ;
367
412
}
413
+
414
+ function listify ( text : string ) {
415
+ // A zero-width space (necessary to prevent discord from trimming the leading whitespace), followed by a three non-breaking spaces.
416
+ const indent = '\u200b\u00a0\u00a0\u00a0' ;
417
+ const bullet = '•' ;
418
+ return text . replace ( / ^ ( \s * ) - / gm, `$1${ bullet } ` ) . replace ( / \t / g, indent ) ;
419
+ }
0 commit comments