locales relative to user

This commit is contained in:
Mylloon 2022-07-21 15:10:48 +02:00
parent 6830f5ffd9
commit d3aee129e0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 9 additions and 8 deletions

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