Skip to content
This repository was archived by the owner on Oct 10, 2024. It is now read-only.

Commit bd09b33

Browse files
Vyvy-viBOLT04
andauthored
fix: made help command concise #330
* fix: made help command concise * fix: ran prettier * fix: implemented suggestion(map) * fix: formatted to code-block * fix: linted code * fix: build issue(any type) * fix: build issue resolved * fix: assigned type as commandHandler(suggestion) * fix: updated import statement(CommandHandler) * feat: improved help command text * fix: linted(why do I keep forgetting :/) * feat: added <usage> in code-block * feat: formatted selective help * fix: attempt to fix build error * fix: cleaned up a bit * fix: another attempt at fixing the build issue * Update src/commandHandlers/help.ts Co-authored-by: David <[email protected]> * Update src/commandHandlers/help.ts Co-authored-by: David <[email protected]> * fix: another eslint run :) * fix: added mapToCodeBlock Co-authored-by: David <[email protected]>
1 parent 6268bed commit bd09b33

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/commandHandlers/help.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MessageEmbed } from 'discord.js';
22

33
import config from '../config';
4-
import commandList from './index';
4+
import commandList, { CommandHandler } from './index';
55

66
const { COMMAND_PREFIX } = config;
77

@@ -10,29 +10,31 @@ export const command = async (arg: [string, string], embed: MessageEmbed) => {
1010
triggers.find((trigger) => trigger === arg[1])
1111
);
1212

13-
embed.setTitle('Help commands').setDescription('Lists the command available');
14-
1513
if (matching) {
16-
embed.addField(
17-
`${COMMAND_PREFIX}${matching.triggers[0]}`,
18-
`${matching.description}\nUsage: ${COMMAND_PREFIX}${matching.usage}`,
19-
false
20-
);
14+
const usageTextOptions = matching.usage.split('or');
15+
const formatted = usageTextOptions.map(mapToCodeBlock).join(' or ');
16+
17+
embed
18+
.setTitle(`${COMMAND_PREFIX}${matching.triggers[0]}`)
19+
.setDescription(
20+
`${matching.description}` + '\nUsage:\t' + `${formatted}`
21+
);
2122
} else {
22-
let text = '';
23-
commandList.forEach((commandItem) => {
24-
text = text
25-
.concat(`**${COMMAND_PREFIX}${commandItem.triggers[0]}** `)
26-
.concat(`${commandItem.description}\n`)
27-
.concat(
28-
'Usage:' + '`' + `${COMMAND_PREFIX}${commandItem.usage}\n` + '`'
29-
);
30-
});
23+
embed
24+
.setTitle('Help commands')
25+
.setDescription(
26+
'These are the available commands. For more information on a specific command, use `^help <commandName>`'
27+
);
28+
const formatWithCodeBlocks = (commandItem: CommandHandler) =>
29+
mapToCodeBlock(commandItem.triggers[0]);
30+
const text = commandList.map(formatWithCodeBlocks).join(' | ');
3131
embed.addField('\u200b', text);
3232
}
3333

3434
return embed;
3535
};
36+
const mapToCodeBlock = (arg: string) =>
37+
'`' + `${COMMAND_PREFIX}` + `${arg}`.trim() + '`';
3638

3739
export const description = 'Lists available commands';
3840

0 commit comments

Comments
 (0)