feat: help command #36
1 changed files with 13 additions and 27 deletions
|
@ -47,33 +47,13 @@ export default {
|
||||||
|
|
||||||
// Load all the command per categories
|
// Load all the command per categories
|
||||||
client.commands.categories.forEach((commands_name, category) => {
|
client.commands.categories.forEach((commands_name, category) => {
|
||||||
const commands_description = commands_name.reduce(
|
const commands = commands_name.reduce((data, command_name) => {
|
||||||
(data, command_name) => {
|
return data + `\`/${command_name}\`, `;
|
||||||
const command = client.commands.list.get(command_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]
|
|
||||||
?? command.data.description;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}, '');
|
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: category.capitalize(),
|
name: category.capitalize() + ` (${commands_name.length})`,
|
||||||
value: commands_description,
|
value: commands.slice(0, -2),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,7 +72,7 @@ export default {
|
||||||
if (!command) {
|
if (!command) {
|
||||||
// Command don't exist
|
// Command don't exist
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: `${loc.get('c_help4')} \`${desired_command}\``,
|
content: `${loc.get('c_help3')} \`${desired_command}\``,
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -102,7 +82,13 @@ export default {
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor('BLURPLE')
|
.setColor('BLURPLE')
|
||||||
.setTitle('`/' + command.data.name + '`')
|
.setTitle('`/' + command.data.name + '`')
|
||||||
.setDescription(command.data.description),
|
.setDescription(
|
||||||
|
// Loads the description
|
||||||
|
// according to the user's locals
|
||||||
|
command.data.description_localizations
|
||||||
|
?.[interaction.locale as Locale]
|
||||||
|
?? command.data.description
|
||||||
|
),
|
||||||
] });
|
] });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue