Skip to content

Commit c977c95

Browse files
committed
abstract list text formatting out of htgh embeds
1 parent 6c30b7a commit c977c95

File tree

1 file changed

+47
-43
lines changed

1 file changed

+47
-43
lines changed

src/modules/helpthread.ts

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ If your issue is not resolved, **you can post another message here and the threa
4040
*If you have a different question, just ask in <#${generalHelpChannel}>.*
4141
`);
4242

43-
// A zero-width space (necessary to prevent discord from trimming the leading whitespace), followed by a three non-breaking spaces.
44-
const indent = '\u200b\u00a0\u00a0\u00a0';
45-
4643
const closedEmoji = '☑️';
4744

4845
const helpInfo = (channel: TextChannel) =>
@@ -55,29 +52,29 @@ const howToGetHelpEmbeds = () => [
5552
.setColor(GREEN)
5653
.setTitle('How To Get Help')
5754
.setDescription(
58-
`
59-
Post your question to one of the channels in this category.
60-
${indent} If you're not sure which channel is best, just post in <#${generalHelpChannel}>.
61-
${indent} It's always ok to just ask your question; you don't need permission.
62-
Our bot will make a thread dedicated to answering your channel.
63-
Someone will (hopefully!) come along and help you.
64-
When your question is resolved, type \`!close\`.
65-
`,
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+
`),
6663
),
6764
new MessageEmbed()
6865
.setColor(GREEN)
6966
.setTitle('How To Get *Better* Help')
7067
.setDescription(
71-
`
72-
Explain what you want to happen and why…
73-
${indent} …and what actually happens, and your best guess at why.
74-
Include a short code sample and any error messages you got.
75-
${indent} Text is better than screenshots. Start code blocks with ${'\\`\\`\\`ts'}.
76-
If possible, create a minimal reproduction in the **[TypeScript Playground](https://www.typescriptlang.org/play)**.
77-
${indent} Send the full link in its own message; do not use a link shortener.
78-
Run \`!title <brief description>\` to make your help thread easier to spot.
79-
For more tips, check out StackOverflow's guide on **[asking good questions](https://stackoverflow.com/help/how-to-ask)**.
80-
`,
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+
`),
8178
),
8279
new MessageEmbed()
8380
.setColor(GREEN)
@@ -95,38 +92,38 @@ const howToGiveHelpEmbeds = () => [
9592
.setColor(GREEN)
9693
.setTitle('How To Give Help')
9794
.setDescription(
98-
`
99-
There are a couple ways you can browse help threads:
100-
${indent} The channel sidebar on the left will list threads you have joined.
101-
${indent} You can scroll through the channel to see all recent questions.
102-
${indent}${indent} The bot will mark closed questions with ${closedEmoji}.
103-
${indent} In the channel, you can click the *⌗*\u2004icon at the top right to view threads by title.
104-
105-
`,
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+
`),
106103
),
107104
new MessageEmbed()
108105
.setColor(GREEN)
109106
.setTitle('How To Give *Better* Help')
110107
.setDescription(
111-
`
112-
Get yourself the <@&${trustedRoleId}> role at <#${rolesChannelId}>
113-
${indent} (If you don't like the pings, you can disable role mentions for the server.)
114-
As a <@&${trustedRoleId}>, you can:
115-
${indent} Run \`!title <brief description>\` to set/update the thread title.
116-
${indent}${indent} This will assist other helpers in finding the thread.
117-
${indent}${indent} Also, it means your help is more accessible to others in the future.
118-
${indent} If a thread appears to be resolved, run \`!close\` to close it.
119-
${indent}${indent} *Only do this if the asker has indicated that their question has been resolved.*
120-
`,
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+
`),
121118
),
122119
new MessageEmbed()
123120
.setColor(GREEN)
124121
.setTitle('Useful Snippets')
125122
.setDescription(
126-
`
127-
\`!screenshot\` — for if an asker posts a screenshot of code
128-
\`!ask\` — for if an asker only posts "can I get help?"
129-
`,
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+
`),
130127
),
131128
];
132129

@@ -413,3 +410,10 @@ export function isHelpThread(
413410
): channel is ThreadChannel & { parent: TextChannel } {
414411
return channel instanceof ThreadChannel && isHelpChannel(channel.parent!);
415412
}
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

Comments
 (0)