mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: new eligible format
This commit is contained in:
1 parent
cda843003c
commit
b4ae5c045a
1 file changed
+80
-67
+80
-67
@@ -11,6 +11,11 @@ import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
|||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
||||||
|
|
||||||
|
export const CLANS = {
|
||||||
|
sklld: 'Skilled',
|
||||||
|
smri: 'Samurai',
|
||||||
|
};
|
||||||
|
|
||||||
export async function execute(
|
export async function execute(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
@@ -18,93 +23,91 @@ export async function execute(
|
|||||||
const server = interaction.options.getString(
|
const server = interaction.options.getString(
|
||||||
'server',
|
'server',
|
||||||
) as keyof typeof SERVERS;
|
) as keyof typeof SERVERS;
|
||||||
|
const clan = interaction.options.getString('clan') as keyof typeof CLANS;
|
||||||
|
|
||||||
getBlitzAccount(interaction, ign, server, async (account) => {
|
getBlitzAccount(interaction, ign, server, async (account) => {
|
||||||
getBlitzStarsAccount(interaction, account.account_id, ign, async (data) => {
|
getBlitzStarsAccount(interaction, account.account_id, ign, async (data) => {
|
||||||
const sklldIssues: string[] = [];
|
const issues: string[] = [];
|
||||||
const smriIssues: string[] = [];
|
|
||||||
|
|
||||||
if (data.period30d.all.battles < 150) {
|
if (clan === 'sklld') {
|
||||||
sklldIssues.push(
|
if (data.period30d.all.battles < 150) {
|
||||||
`**Battles**: ${data.period30d.all.battles} (${
|
issues.push(
|
||||||
data.period30d.all.battles - 150
|
`**Battles**: ${data.period30d.all.battles} (${
|
||||||
})`,
|
data.period30d.all.battles - 150
|
||||||
);
|
})`,
|
||||||
}
|
);
|
||||||
if (data.period30d.avg_tier < 8) {
|
}
|
||||||
sklldIssues.push(
|
if (data.period30d.avg_tier < 8) {
|
||||||
`**Tier**: ${data.period30d.avg_tier.toFixed(2)} (${(
|
issues.push(
|
||||||
data.period30d.avg_tier - 8
|
`**Tier**: ${data.period30d.avg_tier.toFixed(2)} (${(
|
||||||
).toFixed(2)})`,
|
data.period30d.avg_tier - 8
|
||||||
);
|
).toFixed(2)})`,
|
||||||
}
|
);
|
||||||
if (data.period30d.special.winrate < 60) {
|
}
|
||||||
sklldIssues.push(
|
if (data.period30d.special.winrate < 60) {
|
||||||
`**Winrate**: ${data.period30d.special.winrate.toFixed(2)}% (${(
|
issues.push(
|
||||||
data.period30d.special.winrate - 60
|
`**Winrate**: ${data.period30d.special.winrate.toFixed(2)}% (${(
|
||||||
).toFixed(2)}%)`,
|
data.period30d.special.winrate - 60
|
||||||
);
|
).toFixed(2)}%)`,
|
||||||
}
|
);
|
||||||
if (data.period30d.wn8 < 2100) {
|
}
|
||||||
sklldIssues.push(
|
if (data.period30d.wn8 < 2100) {
|
||||||
`**WN8**: ${data.period30d.wn8.toFixed(0)} (${(
|
issues.push(
|
||||||
data.period30d.wn8 - 2100
|
`**WN8**: ${data.period30d.wn8.toFixed(0)} (${(
|
||||||
).toFixed(0)})`,
|
data.period30d.wn8 - 2100
|
||||||
);
|
).toFixed(0)})`,
|
||||||
}
|
);
|
||||||
if (data.period30d.special.dpb < 2400) {
|
}
|
||||||
sklldIssues.push(
|
if (data.period30d.special.dpb < 2400) {
|
||||||
`**Damage per battle**: ${data.period30d.special.dpb.toFixed(0)} (${(
|
issues.push(
|
||||||
data.period30d.special.dpb - 2400
|
`**Damage per battle**: ${data.period30d.special.dpb.toFixed(
|
||||||
).toFixed(0)})`,
|
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)}%)`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.statistics.all.battles < 1500) {
|
const eligible = issues.length === 0;
|
||||||
smriIssues.push(
|
|
||||||
`**Battles**: ${data.statistics.all.battles} (${
|
|
||||||
data.statistics.all.battles - 1500
|
|
||||||
})`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (data.statistics.special.winrate < 53) {
|
|
||||||
smriIssues.push(
|
|
||||||
`**Winrate**: ${data.statistics.special.winrate.toFixed(2)}% (${(
|
|
||||||
data.statistics.special.winrate - 53
|
|
||||||
).toFixed(2)}%)`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
poweredByBlitzStars(
|
poweredByBlitzStars(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle(`${data.nickname}'s eligibility for Skilled clans`)
|
.setTitle(
|
||||||
.setColor(
|
`${data.nickname} is ${eligible ? '' : 'not '}eligible for ${
|
||||||
sklldIssues.length === 0 || smriIssues.length === 0
|
CLANS[clan]
|
||||||
? POSITIVE_COLOR
|
}`,
|
||||||
: NEGATIVE_COLOR,
|
|
||||||
)
|
)
|
||||||
|
.setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${
|
`${
|
||||||
sklldIssues.length === 0
|
eligible
|
||||||
? '**✅ Player is eligible for `[SKLLD]`**'
|
? `${data.nickname} meets all the requirements set for ${CLANS[clan]}.`
|
||||||
: `**❌ \`[SKLLD] short by (30 days):\`**\n${sklldIssues.join(
|
: `${data.nickname}'s shortcomings for ${CLANS[clan]} (${
|
||||||
'\n',
|
clan === 'sklld' ? '30 days stats' : 'career stats'
|
||||||
)}`
|
}):\n\n${issues.join('\n')}`
|
||||||
}\n\n${
|
|
||||||
smriIssues.length === 0
|
|
||||||
? '**✅ Player is eligible for `[SMRI]`**'
|
|
||||||
: `**❌ \`[SMRI] short by (career):\`**\n${smriIssues.join(
|
|
||||||
'\n',
|
|
||||||
)}`
|
|
||||||
}\n\n${blitzLinks(data)}`,
|
}\n\n${blitzLinks(data)}`,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`Showing ${data.nickname}'s eligibility for Skilled clans`);
|
console.log(`Showing ${data.nickname}'s eligibility for ${CLANS[clan]}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -112,6 +115,16 @@ export async function execute(
|
|||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName('eligible')
|
.setName('eligible')
|
||||||
.setDescription("Gets the user's eligibility for Skilled clans")
|
.setDescription("Gets the user's eligibility for Skilled clans")
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('clan')
|
||||||
|
.setDescription('The Skilled clan you are checking')
|
||||||
|
.addChoices(
|
||||||
|
{ name: CLANS.sklld, value: 'sklld' },
|
||||||
|
{ name: CLANS.smri, value: 'smri' },
|
||||||
|
)
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('server')
|
.setName('server')
|
||||||
|
|||||||
Reference in new issue
Block a user