feat: debug command

This commit is contained in:
TrèsAbhi committed 2024-03-05 10:58:41 -06:00
1 parent 8a76558f01
commit e355bd10b1
2 files changed
+23 -12

No files matched your search

+11 -12
View File
@@ -1,6 +1,7 @@
import { SlashCommandBuilder } from 'discord.js';
import packageJSON from '../../package.json' assert { type: 'json' }; import packageJSON from '../../package.json' assert { type: 'json' };
import { client } from '../core/discord/client'; import { client } from '../core/discord/client';
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
import { translator } from '../core/localization/translator';
import { CommandRegistry } from '../events/interactionCreate'; import { CommandRegistry } from '../events/interactionCreate';
const executionStart = new Date().getTime(); const executionStart = new Date().getTime();
@@ -9,28 +10,26 @@ export const debugCommand: CommandRegistry = {
inProduction: true, inProduction: true,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: createLocalizedCommand('debug'),
.setName('debug')
.setDescription('Debug information about the bot'),
async handler() { async handler(interaction) {
const { t } = translator(interaction.locale);
const currentTime = new Date().getTime(); const currentTime = new Date().getTime();
const uptime = currentTime - executionStart; const uptime = currentTime - executionStart;
const list = [ const list = [
['Version', packageJSON.version], [t`bot.commands.debug.body.version`, packageJSON.version],
['Shard', client.shard?.ids[0] ?? 'default'], [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( `${Math.floor((uptime / 1000 / 60 / 60) % 24)}h ${Math.floor(
(uptime / 1000 / 60) % 60, (uptime / 1000 / 60) % 60,
)}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor( )}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor(
uptime % 1000, uptime % 1000,
)}ms`, )}ms`,
], ],
] ];
return t`bot.commands.debug.body.title${list
.map(([key, value]) => `- ${key}: ${value}`) .map(([key, value]) => `- ${key}: ${value}`)
.join('\n'); .join('\n')}`;
return `# Debug\n\n${list}`;
}, },
}; };
+12
View File
@@ -97,6 +97,18 @@
"winrate": "Winrate", "winrate": "Winrate",
"damage": "Damage" "damage": "Damage"
} }
},
"debug": {
"$": "debug",
"description": "Debug information about the bot",
"body": {
"title": "# Debug\n\n",
"version": "Version",
"shard": "Shard",
"uptime": "Uptime"
}
} }
} }
}, },