From 64f61e35e86194a917150ae08bafa6d041475210 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 25 Jul 2022 00:26:03 +0200 Subject: [PATCH] add comments --- src/commands/misc/help.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/commands/misc/help.ts b/src/commands/misc/help.ts index e484a54..bba0cbf 100644 --- a/src/commands/misc/help.ts +++ b/src/commands/misc/help.ts @@ -18,6 +18,7 @@ export default { .setDescriptionLocalizations( getLocalizations(client, `c_${filename}_desc`)) + // Command option .addStringOption(option => option .setName(client.locales.get(client.config.default_lang) ?.get(`c_${filename}_opt1_name`) ?? '') @@ -44,12 +45,16 @@ export default { value: string; }[] = []; + // Load all the command per categories client.commands.categories.forEach((commands_name, category) => { const commands_description = commands_name.reduce( (data, command_name) => { const command = client.commands.list.get(command_name); - data += `- \`/${command?.data.name}\` : `; + data += `- \`/${command_name}\` : `; + // If the command is correct, usually it is if (command?.data) { + // Loads the description + // according to the user's locals const description = command.data.description_localizations ?.[interaction.locale as Locale] @@ -57,9 +62,12 @@ export default { data += `${description}\n`; } else { + // Error message data += `${loc.get('c_help3')}\n`; } + // TODO: Check that `data` does not exceed + // the maximum character limit return data; }, ''); @@ -69,6 +77,7 @@ export default { }); }); + // Sends a list of commands sorted into categories return interaction.reply({ embeds: [ new MessageEmbed() .setColor('BLURPLE') @@ -81,12 +90,14 @@ export default { // If a command is specified const command = client.commands.list.get(desired_command); if (!command) { + // Command don't exist return interaction.reply({ content: `${loc.get('c_help4')} \`${desired_command}\``, ephemeral: true, }); } + // Send information about the command return interaction.reply({ embeds: [ new MessageEmbed() .setColor('BLURPLE')