mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { SlashCommandBuilder } from 'discord.js';
|
|
import markdownEscape from 'markdown-escape';
|
|
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
|
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
|
import embedInfo from '../core/discord/embedInfo';
|
|
import markdownTable from '../core/discord/markdownTable';
|
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
|
import { CommandRegistry } from '../events/interactionCreate';
|
|
|
|
export const playerInfoCommand: CommandRegistry = {
|
|
inProduction: true,
|
|
inPublic: true,
|
|
|
|
command: new SlashCommandBuilder()
|
|
.setName('player-info')
|
|
.setDescription('Basic information about a player')
|
|
.addStringOption(addUsernameChoices),
|
|
|
|
async handler(interaction) {
|
|
const account = await resolvePlayerFromCommand(interaction);
|
|
const { id, region: region } = account;
|
|
const accountInfo = await getAccountInfo(region, id);
|
|
|
|
return embedInfo(
|
|
`${markdownEscape(accountInfo.nickname)}'s information`,
|
|
|
|
markdownTable([
|
|
['Nickname', `${accountInfo.nickname}`],
|
|
['Battles', `${accountInfo.statistics.all.battles}`],
|
|
[
|
|
'Winrate',
|
|
`${(
|
|
100 *
|
|
(accountInfo.statistics.all.wins /
|
|
accountInfo.statistics.all.battles)
|
|
).toFixed(2)}%`,
|
|
],
|
|
[],
|
|
['Account ID', `${accountInfo.account_id}`],
|
|
[
|
|
'Created',
|
|
`${new Date(accountInfo.created_at * 1000).toDateString()}`,
|
|
],
|
|
[
|
|
'Last battle',
|
|
`${new Date(accountInfo.last_battle_time * 1000).toDateString()}`,
|
|
],
|
|
]),
|
|
);
|
|
},
|
|
|
|
autocomplete: autocompleteUsername,
|
|
};
|