feat: more command locales

This commit is contained in:
TrèsAbhi committed 2024-03-08 20:29:35 -06:00
1 parent 38ca1499e2
commit b3a50f2b27
11 files changed
+185 -78

No files matched your search

+13 -12
View File
@@ -1,4 +1,5 @@
import { SlashCommandBuilder } from 'discord.js';
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
import { translator } from '../core/localization/translator';
import { CommandRegistry } from '../events/interactionCreate';
export const pingCommand = new Promise<CommandRegistry>((resolve) => {
@@ -7,28 +8,28 @@ export const pingCommand = new Promise<CommandRegistry>((resolve) => {
inPublic: true,
handlesInteraction: true,
command: new SlashCommandBuilder()
.setName('ping')
.setDescription('Check if the bot is alive')
.addSubcommand((option) =>
option.setName('blitzkrieg').setDescription('Ping Blitzkrieg'),
)
.addSubcommand((option) =>
option.setName('blitz').setDescription('Ping Blitz'),
),
command: createLocalizedCommand('ping', [
{ subcommand: 'blitzkrieg' },
{ subcommand: 'wotb' },
]),
async handler(interaction) {
const { t, translate } = translator(interaction.locale);
const subcommand = interaction.options.getSubcommand();
const executionStart = Date.now();
if (subcommand === 'blitzkrieg') {
await interaction.editReply('Pong 🏓');
await interaction.editReply(t`bot.commands.ping.body.pong`);
} else {
await fetch('https://api.wotblitz.com/');
}
const executionTime = Date.now() - executionStart;
interaction.editReply(`Pong 🏓 - ${executionTime}ms`);
interaction.editReply(
translate('bot.commands.ping.body.pong_with_time', [
`${Math.round(executionTime)}`,
]),
);
},
});
});