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

37 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-10-13 23:15:32 -05:00
import packageJSON from "../../../../package.json";
import { client } from "../core/discord/client";
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
import { translator } from "../core/localization/translator";
import type { CommandRegistry } from "../events/interactionCreate";
2023-04-26 14:23:42 +00:00
const executionStart = new Date().getTime();
2024-03-06 15:34:10 -06:00
export const debugCommand = new Promise<CommandRegistry>((resolve) => {
resolve({
2025-10-13 23:15:32 -05:00
command: createLocalizedCommand("debug"),
2023-04-26 14:23:42 +00:00
2024-03-06 15:34:10 -06:00
async handler(interaction) {
2025-01-16 13:53:29 -06:00
const { strings } = translator(interaction.locale);
2024-03-06 15:34:10 -06:00
const currentTime = new Date().getTime();
const uptime = currentTime - executionStart;
const list = [
2025-01-16 13:53:29 -06:00
[strings.bot.commands.debug.body.version, packageJSON.version],
2024-03-06 15:34:10 -06:00
[
2025-01-18 14:16:49 -06:00
strings.bot.commands.debug.body.shard.label,
2025-01-16 13:53:29 -06:00
client.shard?.ids[0] ?? strings.bot.commands.debug.body.shard.default,
2024-03-06 15:34:10 -06:00
],
[
2025-01-16 13:53:29 -06:00
strings.bot.commands.debug.body.uptime,
2024-03-06 15:34:10 -06:00
`${Math.floor((uptime / 1000 / 60 / 60) % 24)}h ${Math.floor(
2025-10-13 23:15:32 -05:00
(uptime / 1000 / 60) % 60
2024-03-06 15:34:10 -06:00
)}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor(
2025-10-13 23:15:32 -05:00
uptime % 1000
2024-03-06 15:34:10 -06:00
)}ms`,
],
];
2025-01-16 13:53:29 -06:00
return `${strings.bot.commands.debug.body.title}${list
2024-03-06 15:34:10 -06:00
.map(([key, value]) => `- ${key}: ${value}`)
2025-10-13 23:15:32 -05:00
.join("\n")}`;
2024-03-06 15:34:10 -06:00
},
});
});