feat: locales #27
2 changed files with 9 additions and 8 deletions
|
@ -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();
|
||||
}),
|
||||
);
|
||||
}),
|
||||
|
|
|
@ -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.`);
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue