mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: unnecessary code in /tanks
This commit is contained in:
1 parent
8b77baccab
commit
ab725c7f86
1 file changed
+13
-39
@@ -16,9 +16,7 @@ export async function execute(
|
|||||||
) {
|
) {
|
||||||
const server = interaction.options.getString('server') as BlitzServer;
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
let tier = interaction.options.getNumber('tier');
|
const tier = Math.round(interaction.options.getNumber('tier')!);
|
||||||
|
|
||||||
tier = tier === null ? null : Math.round(tier);
|
|
||||||
|
|
||||||
getBlitzAccount(interaction, ign, server, async (account) => {
|
getBlitzAccount(interaction, ign, server, async (account) => {
|
||||||
const tankStats = (await (
|
const tankStats = (await (
|
||||||
@@ -29,25 +27,7 @@ export async function execute(
|
|||||||
|
|
||||||
const tanks = tankStats.data[account.account_id]!.map(
|
const tanks = tankStats.data[account.account_id]!.map(
|
||||||
(tankData) => tankopedia.data[tankData.tank_id],
|
(tankData) => tankopedia.data[tankData.tank_id],
|
||||||
);
|
).filter((tank) => tank.tier === tier);
|
||||||
const tierSortedTanks: Record<number, typeof tanks> = {};
|
|
||||||
const tiers: number[] = [];
|
|
||||||
|
|
||||||
for (const tank of tanks) {
|
|
||||||
if (!tierSortedTanks[tank.tier]) {
|
|
||||||
tierSortedTanks[tank.tier] = [tank];
|
|
||||||
} else {
|
|
||||||
tierSortedTanks[tank.tier].push(tank);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tier === null && !tiers.includes(tank.tier)) tiers.push(tank.tier);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tier === null) {
|
|
||||||
tiers.sort((a, b) => b - a);
|
|
||||||
} else {
|
|
||||||
tiers.push(tier);
|
|
||||||
}
|
|
||||||
|
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -58,22 +38,16 @@ export async function execute(
|
|||||||
}tanks`,
|
}tanks`,
|
||||||
)
|
)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
tiers
|
tanks.length === 0
|
||||||
.map((iterationTier) => {
|
? `No tanks found for player in tier ${tier}`
|
||||||
return `${tier === null ? `**Tier ${iterationTier}**:\n` : ''}${
|
: tanks
|
||||||
tierSortedTanks[iterationTier] === undefined
|
.map(
|
||||||
? `No tanks found for player in tier ${tier}`
|
(tank) =>
|
||||||
: tierSortedTanks[iterationTier]
|
`${tankTypeEmojis[tank.type]} ${tank.name} ${
|
||||||
.map(
|
tank.is_premium ? '⭐' : ''
|
||||||
(tank) =>
|
}`,
|
||||||
`${tankTypeEmojis[tank.type]} ${tank.name} ${
|
)
|
||||||
tank.is_premium ? '⭐' : ''
|
.join('\n'),
|
||||||
}`,
|
|
||||||
)
|
|
||||||
.join('\n')
|
|
||||||
}`;
|
|
||||||
})
|
|
||||||
.join('\n\n'),
|
|
||||||
)
|
)
|
||||||
.setColor(SKILLED_COLOR),
|
.setColor(SKILLED_COLOR),
|
||||||
],
|
],
|
||||||
@@ -82,7 +56,7 @@ export async function execute(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName('ownedtanks')
|
.setName('tanks')
|
||||||
.setDescription("Shows a player's owned tanks")
|
.setDescription("Shows a player's owned tanks")
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
Reference in new issue
Block a user