feat: help command #36

Merged
Anri merged 23 commits from help into main 2022-07-25 00:54:19 +02:00
Showing only changes of commit adad5db364 - Show all commits

View file

@ -17,6 +17,7 @@ export default {
getLocalizations(client, `c_${filename}_name`, true))
.setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_desc`))
.addStringOption(option => option
.setName(client.locales.get(client.config.default_lang)
?.get(`c_${filename}_opt1_name`) ?? '')
@ -36,11 +37,8 @@ export default {
.get(client.config.default_lang)
?.get(`c_${getFilename(__filename)}_opt1_name`) ?? '');
// If a command is specified
if (desired_command) {
// Check if command exists
interaction.reply({ content: 'WIP', ephemeral: true });
} else {
// If a command isn't specified
if (!desired_command) {
const fields: {
name: string;
value: string;
@ -48,21 +46,21 @@ export default {
client.commands.categories.forEach((commands_name, category) => {
const commands_description = commands_name.reduce(
(compteur, command_name) => {
(data, command_name) => {
const command = client.commands.list.get(command_name);
let res = `${compteur}- \`${command_name}\` : `;
data += `- \`/${command?.data.name}\` : `;
if (command?.data) {
const description =
command.data.description_localizations
?.[interaction.locale as Locale]
?? command.data.description;
res += `${description}\n`;
data += `${description}\n`;
} else {
res += `${loc.get('c_help3')}\n`;
data += `${loc.get('c_help3')}\n`;
}
return res;
return data;
}, '');
fields.push({
@ -71,7 +69,7 @@ export default {
});
});
interaction.reply({ embeds: [
return interaction.reply({ embeds: [
new MessageEmbed()
.setColor('BLURPLE')
.setTitle(loc.get('c_help1'))
@ -79,5 +77,21 @@ export default {
.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),
] });
},
};