2023-04-26 00:02:10 +00:00
|
|
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
|
|
|
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
2023-04-25 01:39:43 +00:00
|
|
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
2023-05-02 23:01:54 +00:00
|
|
|
import { BlitzServer } from '../constants/servers.js';
|
2023-04-25 01:39:43 +00:00
|
|
|
import { TanksStats } from '../types/tanksStats.js';
|
2023-05-02 23:01:54 +00:00
|
|
|
import addIGNOption from '../utilities/addIGNOption.js';
|
|
|
|
|
import addServerChoices from '../utilities/addServerChoices.js';
|
2023-04-28 13:42:42 +00:00
|
|
|
import { args } from '../utilities/args.js';
|
2023-04-25 01:39:43 +00:00
|
|
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
2023-04-27 00:21:39 +00:00
|
|
|
import getWargamingResponse from '../utilities/getWargamingResponse.js';
|
2023-04-27 19:55:42 +00:00
|
|
|
import { TANK_TYPE_EMOJIS, tankopedia } from '../utilities/tankopedia.js';
|
|
|
|
|
|
2023-04-28 13:07:51 +00:00
|
|
|
const COMP_TANKS = [
|
2023-04-27 19:55:42 +00:00
|
|
|
// light tanks
|
2023-04-28 13:07:51 +00:00
|
|
|
24321, // t-100 lt
|
|
|
|
|
20257, // sheridan
|
|
|
|
|
3649, // bat chat
|
|
|
|
|
19537, // vickers
|
2023-04-27 19:55:42 +00:00
|
|
|
|
|
|
|
|
// heavy tanks
|
2023-04-28 13:07:51 +00:00
|
|
|
6145, // is-4
|
|
|
|
|
7169, // is-7
|
|
|
|
|
10785, // t110e5
|
|
|
|
|
12161, // strvk
|
|
|
|
|
4481, // kranvagn
|
|
|
|
|
22817, // m6 yoh
|
|
|
|
|
6225, // fv215b
|
|
|
|
|
5425, // wz 113
|
|
|
|
|
7297, // 60tp
|
|
|
|
|
58641, // vk 72
|
|
|
|
|
6753, // type 71
|
|
|
|
|
];
|
2023-04-25 01:39:43 +00:00
|
|
|
|
2023-04-26 00:02:10 +00:00
|
|
|
export default {
|
|
|
|
|
inProduction: true,
|
2023-04-28 13:42:42 +00:00
|
|
|
inDevelopment: false,
|
2023-04-26 00:02:10 +00:00
|
|
|
inPublic: true,
|
2023-04-25 01:39:43 +00:00
|
|
|
|
2023-04-26 00:02:10 +00:00
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
|
.setName('tanks')
|
|
|
|
|
.setDescription("Shows a player's owned tanks")
|
2023-05-02 23:01:54 +00:00
|
|
|
.addStringOption(addServerChoices)
|
|
|
|
|
.addStringOption(addIGNOption)
|
|
|
|
|
.addIntegerOption((option) =>
|
2023-04-26 00:02:10 +00:00
|
|
|
option
|
|
|
|
|
.setName('tier')
|
|
|
|
|
.setDescription('The tier you want to see (default: all tiers)')
|
|
|
|
|
.setMinValue(1)
|
|
|
|
|
.setMaxValue(10)
|
|
|
|
|
.setRequired(true),
|
|
|
|
|
),
|
2023-04-25 01:39:43 +00:00
|
|
|
|
2023-04-26 00:02:10 +00:00
|
|
|
execute(interaction) {
|
|
|
|
|
const server = interaction.options.getString('server') as BlitzServer;
|
2023-04-26 01:23:07 +00:00
|
|
|
const name = interaction.options.getString('name')!;
|
2023-05-02 23:01:54 +00:00
|
|
|
const tier = interaction.options.getInteger('tier')!;
|
2023-04-25 01:39:43 +00:00
|
|
|
|
2023-04-26 01:23:07 +00:00
|
|
|
getBlitzAccount(interaction, name, server, async (account) => {
|
2023-04-27 00:21:39 +00:00
|
|
|
getWargamingResponse<TanksStats>(
|
2023-04-28 13:42:42 +00:00
|
|
|
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${args['wargaming-application-id']}&account_id=${account.account_id}`,
|
2023-04-27 00:21:39 +00:00
|
|
|
interaction,
|
|
|
|
|
async (tankStats) => {
|
|
|
|
|
const tanks = tankStats[account.account_id]!.map(
|
|
|
|
|
(tankData) => tankopedia.data[tankData.tank_id],
|
|
|
|
|
).filter((tank) => tank.tier === tier);
|
2023-04-26 00:02:10 +00:00
|
|
|
|
2023-04-27 01:13:50 +00:00
|
|
|
await interaction.editReply({
|
2023-04-27 00:21:39 +00:00
|
|
|
embeds: [
|
|
|
|
|
new EmbedBuilder()
|
|
|
|
|
.setTitle(
|
|
|
|
|
`${account.nickname}'s owned ${
|
|
|
|
|
tier === null ? '' : `tier ${tier} `
|
|
|
|
|
}tanks`,
|
|
|
|
|
)
|
|
|
|
|
.setDescription(
|
2023-04-27 19:55:42 +00:00
|
|
|
`${
|
|
|
|
|
tanks.length === 0
|
|
|
|
|
? `No tanks found for player in tier ${tier}`
|
|
|
|
|
: tanks
|
|
|
|
|
.map(
|
|
|
|
|
(tank) =>
|
|
|
|
|
`${TANK_TYPE_EMOJIS[tank.type]} ${tank.name} ${
|
|
|
|
|
tank.is_premium ? '⭐' : ''
|
|
|
|
|
}${
|
2023-04-28 13:07:51 +00:00
|
|
|
COMP_TANKS.includes(tank.tank_id) ? '🏆' : ''
|
2023-04-27 19:55:42 +00:00
|
|
|
}`,
|
|
|
|
|
)
|
|
|
|
|
.join('\n')
|
|
|
|
|
}\n\n**Legend**\n⭐ = Premium/Collector\n${
|
|
|
|
|
tier === 10 ? '🏆 = Comp Tank\n' : ''
|
|
|
|
|
}${TANK_TYPE_EMOJIS.heavyTank} = Heavy\n${
|
|
|
|
|
TANK_TYPE_EMOJIS.mediumTank
|
|
|
|
|
} = Medium\n${TANK_TYPE_EMOJIS.lightTank} = Light\n${
|
|
|
|
|
TANK_TYPE_EMOJIS['AT-SPG']
|
|
|
|
|
} = Tank Destroyer`,
|
2023-04-27 00:21:39 +00:00
|
|
|
)
|
|
|
|
|
.setColor(SKILLED_COLOR),
|
|
|
|
|
],
|
|
|
|
|
});
|
2023-04-26 00:02:10 +00:00
|
|
|
|
2023-04-27 00:21:39 +00:00
|
|
|
console.log(
|
|
|
|
|
`Displaying ${account.nickname}'s owned tanks in tier ${tier}`,
|
|
|
|
|
);
|
|
|
|
|
},
|
2023-04-26 14:23:42 +00:00
|
|
|
);
|
2023-04-25 01:39:43 +00:00
|
|
|
});
|
2023-04-26 00:02:10 +00:00
|
|
|
},
|
|
|
|
|
} satisfies CommandRegistry;
|