Merge branch 'dev' into 'main'

Fixed same bug found in checkstats button

See merge request illegitimate/illegitimate-bot!95
This commit is contained in:
2023-11-26 20:19:11 +00:00
2 changed files with 95 additions and 86 deletions

View File

@@ -7,7 +7,6 @@ module.exports = {
name: "check", name: "check",
description: "Check a player's stats.", description: "Check a player's stats.",
type: "slash", type: "slash",
dev: true,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("check") .setName("check")

View File

@@ -67,58 +67,103 @@ module.exports = {
guildTag = " [" + guild.tag + "]" guildTag = " [" + guild.tag + "]"
} }
//bedwars level const statsFields = []
const hsbwexp = player.stats.Bedwars.Experience if (!player.stats) {
const hsbwstars = bedwarsLevel(hsbwexp) statsFields.push({
// bedwars fkdr name: "<a:_warning:1178350183457751100> This player never played any games.",
const hsbwfk = player.stats.Bedwars.final_kills_bedwars value: "**➺ Stats:** `None`"
const hsbwfd = player.stats.Bedwars.final_deaths_bedwars })
const hsbwfkdr = hsbwfk / hsbwfd } else {
// bedwars wins if (player.stats.Bedwars) {
const hsbwwins = player.stats.Bedwars.wins_bedwars const hsbwexp = player.stats?.Bedwars?.Experience || 0
// skywars level const hsbwstars = bedwarsLevel(hsbwexp)
const hsswexp = player.stats.SkyWars.skywars_experience const hsbwfk = player.stats?.Bedwars?.final_kills_bedwars || 0
const hsswstars = skywarsLevel(hsswexp) const hsbwfd = player.stats?.Bedwars?.final_deaths_bedwars || 0
// skywars kdr const hsbwfkdr = hsbwfk / hsbwfd || 0
const hsswkills = player.stats.SkyWars.kills const hsbwwins = player.stats?.Bedwars?.wins_bedwars || 0
const hsswdeaths = player.stats.SkyWars.deaths
const hsswkd = hsswkills / hsswdeaths let bwtitle = ""
//skywars wins if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
const hsswwins = player.stats.SkyWars.wins bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
// dueks kdr } else {
const hsduelskills = player.stats.Duels.kills bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements."
const hsduelsdeaths = player.stats.Duels.deaths }
const hsduelskd = hsduelskills / hsduelsdeaths
// duels wins statsFields.push({
const hsduelswins = player.stats.Duels.wins name: bwtitle,
// duels wlr value: "**➺ Stars:** `" +
const hsduelslosses = player.stats.Duels.losses hsbwstars.toFixed(2).toString() + " / " +
const hsduelswlr = hsduelswins / hsduelslosses bwstars.toString() + "`\n" +
"**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() +
" / " + bwfkdr.toString() + "`\n" +
"**➺ Wins:** `" +
hsbwwins.toString() + " / " +
bwwins.toString() + "`"
})
}
if (player.stats.SkyWars) {
const hsswexp = player.stats.SkyWars.skywars_experience
const hsswstars = skywarsLevel(hsswexp)
const hsswkills = player.stats.SkyWars.kills
const hsswdeaths = player.stats.SkyWars.deaths
const hsswkd = hsswkills / hsswdeaths
const hsswwins = player.stats.SkyWars.wins
let swtitle = ""
if (hsswstars < swstars) {
swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
} else {
swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
}
statsFields.push({
name: swtitle,
value:
"**➺ Stars:** `" +
hsswstars.toFixed(2).toString() +
" / " + swstars.toString() + "`\n" +
"**➺ KDR:** `" +
hsswkd.toFixed(2).toString() + "`\n" +
"**➺ Wins:** `" +
hsswwins.toString() + "`"
})
}
if (player.stats.Duels) {
const hsduelskills = player.stats.Duels.kills
const hsduelsdeaths = player.stats.Duels.deaths
const hsduelskd = hsduelskills / hsduelsdeaths
const hsduelswins = player.stats.Duels.wins
const hsduelslosses = player.stats.Duels.losses
const hsduelswlr = hsduelswins / hsduelslosses
let duelstitle = ""
if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
} else {
duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
}
statsFields.push({
name: duelstitle,
value: "**➺ Wins:** `" +
hsduelswins.toString() +
" / " + duelswins.toString() + "`\n" +
"**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() +
" / " + duelswlr.toString() + "`\n" +
"**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() + "`"
})
}
}
// network level // network level
const hypixelExp = player.networkExp const hypixelExp = player.networkExp || 0
const level = hypixelLevel(hypixelExp) const level = hypixelLevel(hypixelExp)
let bwtitle = ""
let swtitle = ""
let duelstitle = ""
if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
} else {
bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements."
}
if (hsswstars < swstars) {
swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
} else {
swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
}
if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
} else {
duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
}
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [{
title: rank + player.displayname + guildTag, title: rank + player.displayname + guildTag,
@@ -131,42 +176,7 @@ module.exports = {
text: interaction.guild.name + " | Developed by @Taken#0002", text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL() icon_url: interaction.guild.iconURL()
}, },
fields: [ fields: statsFields
{
name: bwtitle,
value: "**➺ Stars:** `" +
hsbwstars.toFixed(2).toString() + " / " +
bwstars.toString() + "`\n" +
"**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() +
" / " + bwfkdr.toString() + "`\n" +
"**➺ Wins:** `" +
hsbwwins.toString() + " / " +
bwwins.toString() + "`"
},
{
name: swtitle,
value:
"**➺ Stars:** `" +
hsswstars.toFixed(2).toString() +
" / " + swstars.toString() + "`\n" +
"**➺ KDR:** `" +
hsswkd.toFixed(2).toString() + "`\n" +
"**➺ Wins:** `" +
hsswwins.toString() + "`"
},
{
name: duelstitle,
value: "**➺ Wins:** `" +
hsduelswins.toString() +
" / " + duelswins.toString() + "`\n" +
"**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() +
" / " + duelswlr.toString() + "`\n" +
"**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() + "`"
}
]
}] }]
}) })
} }