Files
blitzkit/src/commands/debug.ts
T

52 lines
1.8 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-05-30 18:42:34 +00:00
import { tankopedia } from '../core/blitz/tankopedia.js';
2023-06-01 18:36:39 +00:00
import { tankAverages } from '../core/blitzstars/tankaverages.js';
import cleanTable from '../core/interaction/cleanTable.js';
2023-05-13 22:01:58 +00:00
import cmdName from '../core/interaction/cmdName.js';
2023-06-01 18:36:39 +00:00
import infoEmbed from '../core/interaction/infoEmbed.js';
2023-05-13 22:01:58 +00:00
import getClientId from '../core/process/getClientId.js';
2023-05-19 23:50:24 +00:00
import { CommandRegistry } from '../events/interactionCreate.js';
2023-05-21 16:50:05 +00:00
import { client } from '../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-05-28 17:03:12 +00:00
inDevelopment: false,
2023-04-26 14:23:42 +00:00
inPublic: true,
command: new SlashCommandBuilder()
2023-05-13 01:27:12 +00:00
.setName(cmdName('debug'))
2023-04-26 14:23:42 +00:00
.setDescription('Debug information about the bot'),
async execute(interaction) {
const currentTime = new Date().getTime();
const uptime = currentTime - executionStart;
2023-05-08 01:45:57 +00:00
await interaction.editReply({
2023-04-26 14:23:42 +00:00
embeds: [
2023-06-01 18:36:39 +00:00
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
],
});
console.log("Displaying bot's debug information");
},
} satisfies CommandRegistry;