mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: debug command
This commit is contained in:
1 parent
8a76558f01
commit
e355bd10b1
2 files changed
+23
-12
No files matched your search
+11
-12
@@ -1,6 +1,7 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import packageJSON from '../../package.json' assert { type: 'json' };
|
||||
import { client } from '../core/discord/client';
|
||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
||||
import { translator } from '../core/localization/translator';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
|
||||
const executionStart = new Date().getTime();
|
||||
@@ -9,28 +10,26 @@ export const debugCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('debug')
|
||||
.setDescription('Debug information about the bot'),
|
||||
command: createLocalizedCommand('debug'),
|
||||
|
||||
async handler() {
|
||||
async handler(interaction) {
|
||||
const { t } = translator(interaction.locale);
|
||||
const currentTime = new Date().getTime();
|
||||
const uptime = currentTime - executionStart;
|
||||
const list = [
|
||||
['Version', packageJSON.version],
|
||||
['Shard', client.shard?.ids[0] ?? 'default'],
|
||||
[t`bot.commands.debug.body.version`, packageJSON.version],
|
||||
[t`bot.commands.debug.body.shard`, client.shard?.ids[0] ?? 'default'],
|
||||
[
|
||||
'Uptime',
|
||||
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');
|
||||
|
||||
return `# Debug\n\n${list}`;
|
||||
.join('\n')}`;
|
||||
},
|
||||
};
|
||||
@@ -97,6 +97,18 @@
|
||||
"winrate": "Winrate",
|
||||
"damage": "Damage"
|
||||
}
|
||||
},
|
||||
|
||||
"debug": {
|
||||
"$": "debug",
|
||||
"description": "Debug information about the bot",
|
||||
|
||||
"body": {
|
||||
"title": "# Debug\n\n",
|
||||
"version": "Version",
|
||||
"shard": "Shard",
|
||||
"uptime": "Uptime"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user