2023-05-20 00:13:32 +00:00
|
|
|
import { SlashCommandBuilder } from 'discord.js';
|
2023-05-20 00:48:52 +00:00
|
|
|
import markdownEscape from 'markdown-escape';
|
2023-05-20 00:13:32 +00:00
|
|
|
import usernameAutocomplete from '../core/autocomplete/username.js';
|
|
|
|
|
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
|
|
|
|
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
|
|
|
|
import cleanTable from '../core/interaction/cleanTable.js';
|
|
|
|
|
import cmdName from '../core/interaction/cmdName.js';
|
2023-05-21 16:50:05 +00:00
|
|
|
import infoEmbed from '../core/interaction/infoEmbed.js';
|
2023-05-20 00:13:32 +00:00
|
|
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
|
|
|
|
import { args } from '../core/process/args.js';
|
|
|
|
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
|
|
|
|
import { AccountInfo } from '../types/accountInfo.js';
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
inProduction: true,
|
2023-06-03 18:25:33 +00:00
|
|
|
inDevelopment: false,
|
2023-05-20 00:13:32 +00:00
|
|
|
inPublic: true,
|
|
|
|
|
|
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
|
.setName(cmdName('playerinfo'))
|
|
|
|
|
.setDescription('Basic information about a player')
|
|
|
|
|
.addStringOption(addUsernameOption),
|
|
|
|
|
|
|
|
|
|
async execute(interaction) {
|
2023-06-03 18:05:09 +00:00
|
|
|
const account = await getBlitzAccount(interaction);
|
2023-05-20 00:13:32 +00:00
|
|
|
const { id, server } = account;
|
|
|
|
|
const accounts = await getWargamingResponse<AccountInfo>(
|
|
|
|
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${args['wargaming-application-id']}&account_id=${id}`,
|
|
|
|
|
);
|
|
|
|
|
const accountInfo = accounts[id];
|
|
|
|
|
|
|
|
|
|
interaction.editReply({
|
|
|
|
|
embeds: [
|
2023-05-21 16:50:05 +00:00
|
|
|
infoEmbed(
|
2023-05-20 00:48:52 +00:00
|
|
|
`${markdownEscape(accountInfo.nickname)}'s information`,
|
2023-05-20 00:13:32 +00:00
|
|
|
|
|
|
|
|
cleanTable([
|
|
|
|
|
['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: usernameAutocomplete,
|
|
|
|
|
} satisfies CommandRegistry;
|