mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
|
import { translator } from '../core/localization/translator';
|
|
import { CommandRegistry } from '../events/interactionCreate';
|
|
|
|
export const pingCommand = new Promise<CommandRegistry>((resolve) => {
|
|
resolve({
|
|
inProduction: true,
|
|
inPublic: true,
|
|
handlesInteraction: true,
|
|
|
|
command: createLocalizedCommand('ping', [
|
|
{ subcommand: 'blitzrinth' },
|
|
{ subcommand: 'wotb' },
|
|
]),
|
|
|
|
async handler(interaction) {
|
|
const { t, translate } = translator(interaction.locale);
|
|
const subcommand = interaction.options.getSubcommand();
|
|
const executionStart = Date.now();
|
|
|
|
if (subcommand === 'blitzrinth') {
|
|
await interaction.editReply(t`bot.commands.ping.body.pong`);
|
|
} else {
|
|
await fetch('https://api.wotblitz.com/');
|
|
}
|
|
|
|
const executionTime = Date.now() - executionStart;
|
|
interaction.editReply(
|
|
translate('bot.commands.ping.body.pong_with_time', [
|
|
`${Math.round(executionTime)}`,
|
|
]),
|
|
);
|
|
},
|
|
});
|
|
});
|