diff --git a/src/commands/loader.ts b/src/commands/loader.ts index 9dd3e24..aa639f5 100644 --- a/src/commands/loader.ts +++ b/src/commands/loader.ts @@ -25,9 +25,9 @@ export default async (client: Client) => { ).default; // Add it to the collection so the interaction will work - client.commands.set(command.data.name, command); + client.commands.set(command.data(client).name, command); - return command.data.toJSON(); + return command.data(client).toJSON(); }), ); }), diff --git a/src/commands/misc/ping.ts b/src/commands/misc/ping.ts index bbe8903..c6d0573 100644 --- a/src/commands/misc/ping.ts +++ b/src/commands/misc/ping.ts @@ -1,19 +1,20 @@ import { SlashCommandBuilder } from '@discordjs/builders'; import { Client, CommandInteraction, Message } from 'discord.js'; +import { getLocale } from '../../utils/locales'; export default { - data: new SlashCommandBuilder() - .setName('ping') - .setDescription('Pong!'), + data: (client: Client) => new SlashCommandBuilder() + .setNameLocalizations(getLocale(client, 'ping_name')) + .setDescriptionLocalizations(getLocale(client, 'ping_desc')), interaction: async (interaction: CommandInteraction, client: Client) => { - const loc = client.locale; + const loc = client.locales.get(interaction.locale) ?? client.locales.get(client.config.default_lang); const sent = await interaction.reply({ content: 'Pinging...', fetchReply: true }) as Message; interaction.editReply( - `${loc.get('c_ping1')}: \ + `${loc?.get('c_ping1')}: \ ${sent.createdTimestamp - interaction.createdTimestamp}ms -${loc.get('c_ping2')}: ${client.ws.ping}ms.`); +${loc?.get('c_ping2')}: ${client.ws.ping}ms.`); }, };