feat: help command #36
1 changed files with 25 additions and 11 deletions
|
@ -17,6 +17,7 @@ export default {
|
||||||
getLocalizations(client, `c_${filename}_name`, true))
|
getLocalizations(client, `c_${filename}_name`, true))
|
||||||
.setDescriptionLocalizations(
|
.setDescriptionLocalizations(
|
||||||
getLocalizations(client, `c_${filename}_desc`))
|
getLocalizations(client, `c_${filename}_desc`))
|
||||||
|
|
||||||
.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`) ?? '')
|
||||||
|
@ -36,11 +37,8 @@ export default {
|
||||||
.get(client.config.default_lang)
|
.get(client.config.default_lang)
|
||||||
?.get(`c_${getFilename(__filename)}_opt1_name`) ?? '');
|
?.get(`c_${getFilename(__filename)}_opt1_name`) ?? '');
|
||||||
|
|
||||||
// If a command is specified
|
// If a command isn't specified
|
||||||
if (desired_command) {
|
if (!desired_command) {
|
||||||
// Check if command exists
|
|
||||||
interaction.reply({ content: 'WIP', ephemeral: true });
|
|
||||||
} else {
|
|
||||||
const fields: {
|
const fields: {
|
||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
@ -48,21 +46,21 @@ export default {
|
||||||
|
|
||||||
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(
|
||||||
(compteur, command_name) => {
|
(data, command_name) => {
|
||||||
const command = client.commands.list.get(command_name);
|
const command = client.commands.list.get(command_name);
|
||||||
let res = `${compteur}- \`${command_name}\` : `;
|
data += `- \`/${command?.data.name}\` : `;
|
||||||
if (command?.data) {
|
if (command?.data) {
|
||||||
const description =
|
const description =
|
||||||
command.data.description_localizations
|
command.data.description_localizations
|
||||||
?.[interaction.locale as Locale]
|
?.[interaction.locale as Locale]
|
||||||
?? command.data.description;
|
?? command.data.description;
|
||||||
|
|
||||||
res += `${description}\n`;
|
data += `${description}\n`;
|
||||||
} else {
|
} else {
|
||||||
res += `${loc.get('c_help3')}\n`;
|
data += `${loc.get('c_help3')}\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return data;
|
||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
|
@ -71,7 +69,7 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
interaction.reply({ embeds: [
|
return interaction.reply({ embeds: [
|
||||||
new MessageEmbed()
|
new MessageEmbed()
|
||||||
.setColor('BLURPLE')
|
.setColor('BLURPLE')
|
||||||
.setTitle(loc.get('c_help1'))
|
.setTitle(loc.get('c_help1'))
|
||||||
|
@ -79,5 +77,21 @@ export default {
|
||||||
.addFields(fields),
|
.addFields(fields),
|
||||||
] });
|
] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a command is specified
|
||||||
|
const command = client.commands.list.get(desired_command);
|
||||||
|
if (!command) {
|
||||||
|
return interaction.reply({
|
||||||
|
content: `${loc.get('c_help4')} \`${desired_command}\``,
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return interaction.reply({ embeds: [
|
||||||
|
new MessageEmbed()
|
||||||
|
.setColor('BLURPLE')
|
||||||
|
.setTitle('`/' + command.data.name + '`')
|
||||||
|
.setDescription(command.data.description),
|
||||||
|
] });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue