Compare commits
No commits in common. "b3fb838920cbc52cc44056825f5a31babe484a8c" and "2c276649791ee5556e18fdf85dc48a47a10556c4" have entirely different histories.
b3fb838920
...
2c27664979
3 changed files with 19 additions and 54 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||||
import { Locale } from 'discord-api-types/v9';
|
|
||||||
import { Client, CommandInteraction, MessageEmbed } from 'discord.js';
|
import { Client, CommandInteraction, MessageEmbed } from 'discord.js';
|
||||||
import { getLocale, getLocalizations } from '../../utils/locales';
|
import { getLocale, getLocalizations } from '../../utils/locales';
|
||||||
import { getFilename } from '../../utils/misc';
|
import { getFilename } from '../../utils/misc';
|
||||||
|
@ -8,32 +7,15 @@ export default {
|
||||||
data: (client: Client) => {
|
data: (client: Client) => {
|
||||||
const filename = getFilename(__filename);
|
const filename = getFilename(__filename);
|
||||||
return new SlashCommandBuilder()
|
return new SlashCommandBuilder()
|
||||||
.setName(
|
.setName(filename.toLowerCase())
|
||||||
filename.toLowerCase())
|
.setDescription(client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? '')
|
||||||
.setDescription(client.locales.get(client.config.default_lang)
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
?.get(`c_${filename}_desc`) ?? '')
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`));
|
||||||
.setNameLocalizations(
|
|
||||||
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`) ?? '')
|
|
||||||
.setDescription(client.locales.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_opt1_desc`) ?? '')
|
|
||||||
.setNameLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_name`, true))
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_desc`))
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
interaction: async (interaction: CommandInteraction, client: Client) => {
|
interaction: async (interaction: CommandInteraction, client: Client) => {
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const desired_command = interaction.options.getString(client
|
const desired_command = interaction.options.getString('command');
|
||||||
.locales
|
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${getFilename(__filename)}_opt1_name`) ?? '');
|
|
||||||
|
|
||||||
// If a command is specified
|
// If a command is specified
|
||||||
if (desired_command) {
|
if (desired_command) {
|
||||||
|
@ -46,17 +28,11 @@ 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) => {
|
||||||
(compteur, command_name) => {
|
|
||||||
const command = client.commands.list.get(command_name);
|
const command = client.commands.list.get(command_name);
|
||||||
let res = `${compteur}- \`${command_name}\` : `;
|
let res = `${compteur}- \`${command_name}\` : `;
|
||||||
if (command?.data) {
|
if (command?.data) {
|
||||||
const description =
|
res += `${command.data.description}.\n`;
|
||||||
command.data.description_localizations
|
|
||||||
?.[interaction.locale as Locale]
|
|
||||||
?? command.data.description;
|
|
||||||
|
|
||||||
res += `${description}\n`;
|
|
||||||
} else {
|
} else {
|
||||||
res += `${loc.get('c_help3')}\n`;
|
res += `${loc.get('c_help3')}\n`;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +41,7 @@ export default {
|
||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: category.toUpperCase(),
|
name: category,
|
||||||
value: commands_description,
|
value: commands_description,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
{
|
{
|
||||||
"e_interacreate_no_command": "Sorry, the command probably no longer exists...",
|
"e_interacreate_no_command": "Sorry, the command probably no longer exists...",
|
||||||
|
|
||||||
"c_ping_name": "Ping",
|
|
||||||
"c_ping_desc": "Pong!",
|
"c_ping_desc": "Pong!",
|
||||||
"c_ping1": "Roundtrip latency",
|
"c_ping1": "Roundtrip latency",
|
||||||
"c_ping2": "Websocket heartbeat",
|
"c_ping2": "Websocket heartbeat"
|
||||||
|
|
||||||
"c_help_name": "Help",
|
|
||||||
"c_help_desc": "Informations about commands",
|
|
||||||
"c_help_opt1_name": "command",
|
|
||||||
"c_help_opt1_desc": "Command wanted in depth.",
|
|
||||||
"c_help1": "List of categories and associated commands",
|
|
||||||
"c_help2": "`/help <command>` to get more information about a command.",
|
|
||||||
"c_help3": "No information available."
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
"c_ping1": "Latence totale",
|
"c_ping1": "Latence totale",
|
||||||
"c_ping2": "Latence du Websocket",
|
"c_ping2": "Latence du Websocket",
|
||||||
|
|
||||||
"c_help_name": "Aide",
|
"c_help_name": "Help",
|
||||||
"c_help_desc": "Informations sur les commandes",
|
"c_help_desc": "Aide",
|
||||||
"c_help_opt1_name": "commande",
|
|
||||||
"c_help_opt1_desc": "Commande voulu en détail.",
|
|
||||||
"c_help1": "Liste des catégories et des commandes associées",
|
"c_help1": "Liste des catégories et des commandes associées",
|
||||||
"c_help2": "`/help <commande>` pour obtenir plus d'informations sur une commande.",
|
"c_help2": "`/help <commande>` pour obtenir plus d'informations sur une commande.",
|
||||||
"c_help3": "Pas d'information."
|
"c_help3": "Pas d'information."
|
||||||
|
|
Loading…
Reference in a new issue