Request for help command
Olympic1 opened this issue · comments
Regarding your todo in the help command:
https://github.com/Dev-CasperTheGhost/ghostybot/blob/1c0a08c73f7eda0d91a9bd1f8f9d9332ab0b02a0/src/interactions/util/Help.ts#L43
What I have in my bot is that every command has a category
key.
Then in my help command I loop through all my commands and create a collection with all the categories and the commands that belong that that category.
const categories: Collection<string, string[]> = new Collection();
for (const command of client.commands.values()) {
// If the command doesn't have a category, move to the next one
if (!command.category) continue;
const category = command.category;
// If the category isn't in the collection yet, add it along with the command.
// If the category is already in the collection, add the command to it.
if (!categories.has(category)) {
categories.set(category, [command.name]);
} else {
const cmd = categories.get(category);
cmd?.push(command.name);
}
}
When I need all the categories, I loop through the keys of the collection:
for (const category of categories.keys()) {
// Add options to select menu
}
When I need the commands for the selected category, I get the respective category:
if (categories.has(selectedCategory)) {
const commands = categories.get(selectedCategory);
// Simplified for this issue
embed.setDescription(`\`${commands?.join('`, `')}\``)
}
I currently don’t have time for this yet, but thanks for looking into this!