mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: heavy usage of await
This commit is contained in:
1 parent
18360dfe8f
commit
91af52b4b8
14 files changed
+569
-666
No files matched your search
+96
-95
@@ -43,106 +43,107 @@ export default {
|
||||
if (!extractedUser) return;
|
||||
|
||||
const { name, server } = extractedUser;
|
||||
const command = `eligible ${server} ${name} ${clan}`;
|
||||
|
||||
getBlitzAccount(interaction, command, name, server, async (account) => {
|
||||
getBlitzStarsAccount(
|
||||
interaction,
|
||||
command,
|
||||
account.account_id,
|
||||
name,
|
||||
async (data) => {
|
||||
const issues: string[] = [];
|
||||
const blitzAccount = await getBlitzAccount(interaction, name, server);
|
||||
if (!blitzAccount) return;
|
||||
|
||||
if (clan === 'sklld') {
|
||||
if (data.period30d.all.battles < 150) {
|
||||
issues.push(
|
||||
`**Battles**: ${data.period30d.all.battles} (${
|
||||
data.period30d.all.battles - 150
|
||||
})`,
|
||||
);
|
||||
}
|
||||
if (data.period30d.avg_tier < 8) {
|
||||
issues.push(
|
||||
`**Tier**: ${data.period30d.avg_tier.toFixed(2)} (${(
|
||||
data.period30d.avg_tier - 8
|
||||
).toFixed(2)})`,
|
||||
);
|
||||
}
|
||||
if (data.period30d.special.winrate < 60) {
|
||||
issues.push(
|
||||
`**Winrate**: ${data.period30d.special.winrate.toFixed(2)}% (${(
|
||||
data.period30d.special.winrate - 60
|
||||
).toFixed(2)}%)`,
|
||||
);
|
||||
}
|
||||
if (data.period30d.wn8 < 2100) {
|
||||
issues.push(
|
||||
`**WN8**: ${data.period30d.wn8.toFixed(0)} (${(
|
||||
data.period30d.wn8 - 2100
|
||||
).toFixed(0)})`,
|
||||
);
|
||||
}
|
||||
if (data.period30d.special.dpb < 2400) {
|
||||
issues.push(
|
||||
`**Damage per battle**: ${data.period30d.special.dpb.toFixed(
|
||||
0,
|
||||
)} (${(data.period30d.special.dpb - 2400).toFixed(0)})`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (data.statistics.all.battles < 1500) {
|
||||
issues.push(
|
||||
`**Battles**: ${data.statistics.all.battles} (${
|
||||
data.statistics.all.battles - 1500
|
||||
})`,
|
||||
);
|
||||
}
|
||||
if (data.statistics.special.winrate < 53) {
|
||||
issues.push(
|
||||
`**Winrate**: ${data.statistics.special.winrate.toFixed(
|
||||
2,
|
||||
)}% (${(data.statistics.special.winrate - 53).toFixed(2)}%)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
const blitzStarsAccount = await getBlitzStarsAccount(
|
||||
interaction,
|
||||
blitzAccount.account_id,
|
||||
name,
|
||||
);
|
||||
if (!blitzStarsAccount) return;
|
||||
|
||||
const eligible = issues.length === 0;
|
||||
const issues: string[] = [];
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
poweredByBlitzStars(
|
||||
new EmbedBuilder()
|
||||
.setTitle(
|
||||
`${markdownEscape(data.nickname)} is ${
|
||||
eligible ? '' : 'not '
|
||||
}eligible for ${CLANS[clan].name}`,
|
||||
)
|
||||
.setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR)
|
||||
.setDescription(
|
||||
`${
|
||||
eligible
|
||||
? `${markdownEscape(
|
||||
data.nickname,
|
||||
)} meets all the requirements set for ${
|
||||
CLANS[clan].name
|
||||
}.`
|
||||
: `${markdownEscape(
|
||||
data.nickname,
|
||||
)}'s shortcomings for ${CLANS[clan].name} (${
|
||||
clan === 'sklld' ? '30 days stats' : 'career stats'
|
||||
}):\n\n${issues.join('\n')}`
|
||||
}\n\n${blitzLinks(data)}`,
|
||||
),
|
||||
),
|
||||
],
|
||||
});
|
||||
if (clan === 'sklld') {
|
||||
if (blitzStarsAccount.period30d.all.battles < 150) {
|
||||
issues.push(
|
||||
`**Battles**: ${blitzStarsAccount.period30d.all.battles} (${
|
||||
blitzStarsAccount.period30d.all.battles - 150
|
||||
})`,
|
||||
);
|
||||
}
|
||||
if (blitzStarsAccount.period30d.avg_tier < 8) {
|
||||
issues.push(
|
||||
`**Tier**: ${blitzStarsAccount.period30d.avg_tier.toFixed(2)} (${(
|
||||
blitzStarsAccount.period30d.avg_tier - 8
|
||||
).toFixed(2)})`,
|
||||
);
|
||||
}
|
||||
if (blitzStarsAccount.period30d.special.winrate < 60) {
|
||||
issues.push(
|
||||
`**Winrate**: ${blitzStarsAccount.period30d.special.winrate.toFixed(
|
||||
2,
|
||||
)}% (${(blitzStarsAccount.period30d.special.winrate - 60).toFixed(
|
||||
2,
|
||||
)}%)`,
|
||||
);
|
||||
}
|
||||
if (blitzStarsAccount.period30d.wn8 < 2100) {
|
||||
issues.push(
|
||||
`**WN8**: ${blitzStarsAccount.period30d.wn8.toFixed(0)} (${(
|
||||
blitzStarsAccount.period30d.wn8 - 2100
|
||||
).toFixed(0)})`,
|
||||
);
|
||||
}
|
||||
if (blitzStarsAccount.period30d.special.dpb < 2400) {
|
||||
issues.push(
|
||||
`**Damage per battle**: ${blitzStarsAccount.period30d.special.dpb.toFixed(
|
||||
0,
|
||||
)} (${(blitzStarsAccount.period30d.special.dpb - 2400).toFixed(0)})`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (blitzStarsAccount.statistics.all.battles < 1500) {
|
||||
issues.push(
|
||||
`**Battles**: ${blitzStarsAccount.statistics.all.battles} (${
|
||||
blitzStarsAccount.statistics.all.battles - 1500
|
||||
})`,
|
||||
);
|
||||
}
|
||||
if (blitzStarsAccount.statistics.special.winrate < 53) {
|
||||
issues.push(
|
||||
`**Winrate**: ${blitzStarsAccount.statistics.special.winrate.toFixed(
|
||||
2,
|
||||
)}% (${(blitzStarsAccount.statistics.special.winrate - 53).toFixed(
|
||||
2,
|
||||
)}%)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Showing ${data.nickname}'s eligibility for ${CLANS[clan].name}`,
|
||||
);
|
||||
},
|
||||
);
|
||||
const eligible = issues.length === 0;
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
poweredByBlitzStars(
|
||||
new EmbedBuilder()
|
||||
.setTitle(
|
||||
`${markdownEscape(blitzStarsAccount.nickname)} is ${
|
||||
eligible ? '' : 'not '
|
||||
}eligible for ${CLANS[clan].name}`,
|
||||
)
|
||||
.setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR)
|
||||
.setDescription(
|
||||
`${
|
||||
eligible
|
||||
? `${markdownEscape(
|
||||
blitzStarsAccount.nickname,
|
||||
)} meets all the requirements set for ${CLANS[clan].name}.`
|
||||
: `${markdownEscape(
|
||||
blitzStarsAccount.nickname,
|
||||
)}'s shortcomings for ${CLANS[clan].name} (${
|
||||
clan === 'sklld' ? '30 days stats' : 'career stats'
|
||||
}):\n\n${issues.join('\n')}`
|
||||
}\n\n${blitzLinks(blitzStarsAccount)}`,
|
||||
),
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
console.log(
|
||||
`Showing ${blitzStarsAccount.nickname}'s eligibility for ${CLANS[clan].name}`,
|
||||
);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
Reference in new issue
Block a user