Files
blitzkit/packages/bot/src/commands/ping.ts
T

34 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-10-01 22:45:21 -05:00
import { literals } from "@blitzkit/i18n";
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
import { translator } from "../core/localization/translator";
import { CommandRegistry } from "../events/interactionCreate";
2023-06-17 18:16:41 +00:00
2024-03-06 15:34:10 -06:00
export const pingCommand = new Promise<CommandRegistry>((resolve) => {
resolve({
handlesInteraction: true,
2023-06-17 18:16:41 +00:00
2025-10-01 22:45:21 -05:00
command: createLocalizedCommand("ping", [
{ subcommand: "blitzkit" },
{ subcommand: "wotb" },
2024-03-08 20:29:35 -06:00
]),
2023-06-17 18:16:41 +00:00
2024-03-06 15:34:10 -06:00
async handler(interaction) {
2025-01-16 13:48:13 -06:00
const { strings } = translator(interaction.locale);
2024-03-06 15:34:10 -06:00
const subcommand = interaction.options.getSubcommand();
const executionStart = Date.now();
2023-06-23 17:10:18 +00:00
2025-10-01 22:45:21 -05:00
if (subcommand === "blitzkit") {
2025-01-16 13:48:13 -06:00
await interaction.editReply(strings.bot.commands.ping.body.pong);
2024-03-06 15:34:10 -06:00
} else {
2025-10-01 22:45:21 -05:00
await fetch("https://api.wotblitz.com/");
2024-03-06 15:34:10 -06:00
}
2023-06-23 17:10:18 +00:00
2024-03-06 15:34:10 -06:00
const executionTime = Date.now() - executionStart;
2024-03-08 20:29:35 -06:00
interaction.editReply(
2025-10-01 22:45:21 -05:00
literals(strings.bot.commands.ping.body.pong_with_time, {
time: executionTime.toFixed(0),
})
2024-03-08 20:29:35 -06:00
);
2024-03-06 15:34:10 -06:00
},
});
});