From a85789830001e1c4b34cd0e72011119a14ddfc04 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 24 Jul 2022 15:46:01 +0200 Subject: [PATCH] show categories, commands name and desc --- src/commands/misc/help.ts | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/commands/misc/help.ts b/src/commands/misc/help.ts index 3540301..47af03f 100644 --- a/src/commands/misc/help.ts +++ b/src/commands/misc/help.ts @@ -9,23 +9,41 @@ export default { return new SlashCommandBuilder() .setName(filename.toLowerCase()) .setDescription(client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? '') - .setNameLocalizations(getLocalizations(client, `c_${filename}_name`)) + .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)); }, interaction: async (interaction: CommandInteraction, client: Client) => { const loc = getLocale(client, interaction.locale); - const command_name = interaction.options.getString('command'); + const desired_command = interaction.options.getString('command'); // If a command is specified - if (command_name) { + if (desired_command) { // Check if command exists interaction.reply({ content: 'WIP', ephemeral: true }); } else { - const fields = []; - fields.push({ - name: 'WIP', - value: 'WIP', + const fields: { + name: string; + value: string; + }[] = []; + + client.commands.categories.forEach((commands_name, category) => { + const commands_description = commands_name.reduce((compteur, command_name) => { + const command = client.commands.list.get(command_name); + let res = `${compteur}- \`${command_name}\` : `; + if (command?.data) { + res += `${command.data(client).description}.\n`; + } else { + res += loc.get('c_help3'); + } + + return res; + }, ''); + + fields.push({ + name: category, + value: commands_description, + }); }); interaction.reply({ embeds: [