feat: locales #27

Merged
Anri merged 26 commits from lang into main 2022-07-22 11:46:48 +02:00
2 changed files with 9 additions and 8 deletions
Showing only changes of commit d3aee129e0 - Show all commits

View file

@ -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();
}),
);
}),

View file

@ -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.`);
},
};