Files
blitzkit/src/commands/debug.ts
T

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-04-26 14:23:42 +00:00
import packageJSON from '../../package.json' assert { type: '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();
2023-07-05 01:15:18 +00:00
export const debugCommand: CommandRegistry = {
2023-04-26 23:43:43 +00:00
inProduction: true,
2023-04-26 14:23:42 +00:00
inPublic: true,
2024-03-05 10:58:41 -06:00
command: createLocalizedCommand('debug'),
2023-04-26 14:23:42 +00:00
2024-03-05 10:58:41 -06:00
async handler(interaction) {
const { t } = translator(interaction.locale);
2023-04-26 14:23:42 +00:00
const currentTime = new Date().getTime();
const uptime = currentTime - executionStart;
2023-11-25 20:46:20 -06:00
const list = [
2024-03-05 10:58:41 -06:00
[t`bot.commands.debug.body.version`, packageJSON.version],
2024-03-05 11:00:53 -06:00
[
t`bot.commands.debug.body.shard`,
client.shard?.ids[0] ?? t`bot.commands.debug.body.shard.default`,
],
2023-11-25 20:46:20 -06:00
[
2024-03-05 10:58:41 -06:00
t`bot.commands.debug.body.uptime`,
2023-11-25 20:46:20 -06:00
`${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`,
],
2024-03-05 10:58:41 -06:00
];
return t`bot.commands.debug.body.title${list
2023-11-25 20:46:20 -06:00
.map(([key, value]) => `- ${key}: ${value}`)
2024-03-05 10:58:41 -06:00
.join('\n')}`;
2023-04-26 14:23:42 +00:00
},
2023-07-05 01:15:18 +00:00
};