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

37 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-11-29 11:56:22 -06:00
import packageJSON from '../../../../package.json';
2023-10-14 11:32:02 -05:00
import { client } from '../core/discord/client';
2024-03-05 10:58:41 -06:00
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
import { translator } from '../core/localization/translator';
2023-07-11 19:54:57 +00:00
import { 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({
command: createLocalizedCommand('debug'),
2023-04-26 14:23:42 +00:00
2024-03-06 15:34:10 -06:00
async handler(interaction) {
const { t } = translator(interaction.locale);
const currentTime = new Date().getTime();
const uptime = currentTime - executionStart;
const list = [
[t`bot.commands.debug.body.version`, packageJSON.version],
[
t`bot.commands.debug.body.shard`,
client.shard?.ids[0] ?? t`bot.commands.debug.body.shard.default`,
],
[
t`bot.commands.debug.body.uptime`,
`${Math.floor((uptime / 1000 / 60 / 60) % 24)}h ${Math.floor(
(uptime / 1000 / 60) % 60,
)}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor(
uptime % 1000,
)}ms`,
],
];
return t`bot.commands.debug.body.title${list
.map(([key, value]) => `- ${key}: ${value}`)
.join('\n')}`;
},
});
});