Files
blitzkit/src/commands/debug.ts
T

45 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-06-01 18:36:39 +00:00
import { SlashCommandBuilder } from 'discord.js';
2023-04-26 14:23:42 +00:00
import packageJSON from '../../package.json' assert { type: 'json' };
2023-06-26 15:05:05 +00:00
import { client } from '../bot.js';
2023-05-30 18:42:34 +00:00
import { tankopedia } from '../core/blitz/tankopedia.js';
2023-06-02 01:31:14 +00:00
import { tankAverages } from '../core/blitzstars/tankAverages.js';
2023-06-01 18:36:39 +00:00
import cleanTable from '../core/interaction/cleanTable.js';
import infoEmbed from '../core/interaction/infoEmbed.js';
2023-05-13 22:01:58 +00:00
import getClientId from '../core/process/getClientId.js';
2023-06-25 02:32:56 +00:00
import { CommandRegistry } from '../events/interactionCreate/index.js';
2023-04-26 14:23:42 +00:00
const executionStart = new Date().getTime();
2023-04-26 14:23:42 +00:00
export default {
2023-04-26 23:43:43 +00:00
inProduction: true,
2023-06-23 17:14:27 +00:00
inDevelopment: false,
2023-04-26 14:23:42 +00:00
inPublic: true,
command: new SlashCommandBuilder()
.setName('debug')
2023-04-26 14:23:42 +00:00
.setDescription('Debug information about the bot'),
2023-06-16 02:01:06 +00:00
execute(interaction) {
2023-04-26 14:23:42 +00:00
const currentTime = new Date().getTime();
const uptime = currentTime - executionStart;
2023-06-16 02:01:06 +00:00
return infoEmbed(
`${client.user?.username} debug information`,
cleanTable([
['Version', packageJSON.version],
['Client ID', getClientId()],
['Tag', interaction.client.user.tag],
[
'Uptime',
`${Math.floor(uptime / 1000 / 60 / 60 / 24)}d ${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`,
],
['Tankopedia cached', `${tankopedia !== undefined}`],
['Tank averages cached', `${tankAverages !== undefined}`],
]),
);
2023-04-26 14:23:42 +00:00
},
} satisfies CommandRegistry;