add comments
This commit is contained in:
parent
adad5db364
commit
64f61e35e8
1 changed files with 12 additions and 1 deletions
|
@ -18,6 +18,7 @@ export default {
|
||||||
.setDescriptionLocalizations(
|
.setDescriptionLocalizations(
|
||||||
getLocalizations(client, `c_${filename}_desc`))
|
getLocalizations(client, `c_${filename}_desc`))
|
||||||
|
|
||||||
|
// Command option
|
||||||
.addStringOption(option => option
|
.addStringOption(option => option
|
||||||
.setName(client.locales.get(client.config.default_lang)
|
.setName(client.locales.get(client.config.default_lang)
|
||||||
?.get(`c_${filename}_opt1_name`) ?? '')
|
?.get(`c_${filename}_opt1_name`) ?? '')
|
||||||
|
@ -44,12 +45,16 @@ export default {
|
||||||
value: string;
|
value: string;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
|
// 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_description = commands_name.reduce(
|
||||||
(data, command_name) => {
|
(data, command_name) => {
|
||||||
const command = client.commands.list.get(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) {
|
if (command?.data) {
|
||||||
|
// Loads the description
|
||||||
|
// according to the user's locals
|
||||||
const description =
|
const description =
|
||||||
command.data.description_localizations
|
command.data.description_localizations
|
||||||
?.[interaction.locale as Locale]
|
?.[interaction.locale as Locale]
|
||||||
|
@ -57,9 +62,12 @@ export default {
|
||||||
|
|
||||||
data += `${description}\n`;
|
data += `${description}\n`;
|
||||||
} else {
|
} else {
|
||||||
|
// Error message
|
||||||
data += `${loc.get('c_help3')}\n`;
|
data += `${loc.get('c_help3')}\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Check that `data` does not exceed
|
||||||
|
// the maximum character limit
|
||||||
return data;
|
return data;
|
||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
|
@ -69,6 +77,7 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Sends a list of commands sorted into categories
|
||||||
return interaction.reply({ embeds: [
|
return interaction.reply({ embeds: [
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor('BLURPLE')
|
.setColor('BLURPLE')
|
||||||
|
@ -81,12 +90,14 @@ export default {
|
||||||
// If a command is specified
|
// If a command is specified
|
||||||
const command = client.commands.list.get(desired_command);
|
const command = client.commands.list.get(desired_command);
|
||||||
if (!command) {
|
if (!command) {
|
||||||
|
// Command don't exist
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: `${loc.get('c_help4')} \`${desired_command}\``,
|
content: `${loc.get('c_help4')} \`${desired_command}\``,
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send information about the command
|
||||||
return interaction.reply({ embeds: [
|
return interaction.reply({ embeds: [
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor('BLURPLE')
|
.setColor('BLURPLE')
|
||||||
|
|
Loading…
Reference in a new issue