Files
blitzkit/src/commands/debug.ts
T

48 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-04-26 14:23:42 +00:00
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import packageJSON from '../../package.json' assert { type: 'json' };
import { SKILLED_COLOR } from '../constants/colors.js';
2023-05-13 22:01:58 +00:00
import { tankopedia } from '../core/blitzstars/tankopedia.js';
import cmdName from '../core/interaction/cmdName.js';
import getClientId from '../core/process/getClientId.js';
2023-05-06 18:03:37 +00:00
import { client } from '../index.js';
2023-05-19 23:50:24 +00:00
import { CommandRegistry } from '../events/interactionCreate.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-16 02:02:50 +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: [
new EmbedBuilder()
2023-04-28 13:52:31 +00:00
.setTitle(`${client.user?.username} debug information`)
2023-04-26 14:23:42 +00:00
.setColor(SKILLED_COLOR)
.setDescription(
`**Version**: ${packageJSON.version}\n**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\n**Tankopedia**: ${
tankopedia ? 'cached' : 'not cached'
}\n**Client ID**: ${getClientId()}\n**Tag**: ${
interaction.client.user.tag
}`,
),
],
});
console.log("Displaying bot's debug information");
},
} satisfies CommandRegistry;