From 2d0214c186b10ef9e461706b938f19764a20919a Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 26 Nov 2023 16:29:57 +0100 Subject: [PATCH] Fixed anthoer bug --- src/commands/check.js | 192 ++++++++++++++++++++++-------------------- 1 file changed, 100 insertions(+), 92 deletions(-) diff --git a/src/commands/check.js b/src/commands/check.js index 42c8bfd..cfe8fc9 100644 --- a/src/commands/check.js +++ b/src/commands/check.js @@ -87,115 +87,123 @@ module.exports = { } const statsFields = [] - if (player.stats.Bedwars) { - const hsbwexp = player.stats.Bedwars.Experience || 0 - const hsbwstars = bedwarsLevel(hsbwexp) - const hsbwfk = player.stats?.Bedwars?.final_kills_bedwars || 0 - const hsbwfd = player.stats?.Bedwars?.final_deaths_bedwars || 0 - const hsbwfkdr = hsbwfk / hsbwfd || 0 - const hsbwwins = player.stats.Bedwars.wins_bedwars || 0 - - let bwtitle = "" - if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) { - bwtitle = - " This player does not meet the BedWars requirements." - } else { - bwtitle = - " This player meets the BedWars requirements." - } + if (!player.stats) { statsFields.push({ - name: bwtitle, - value: "**➺ Stars:** `" + - hsbwstars.toFixed(2).toString() + " / " + - bwstars.toString() + "`\n" + - "**➺ FKDR:** `" + - hsbwfkdr.toFixed(2).toString() + - " / " + bwfkdr.toString() + "`\n" + - "**➺ Wins:** `" + - hsbwwins.toString() + " / " + - bwwins.toString() + "`" - }) - } else { - statsFields.push({ - name: " This player never played BedWars.", + name: " This player never played any games.", value: "**➺ Stats:** `None`" }) - } + } else { + if (player.stats.Bedwars) { + const hsbwexp = player.stats.Bedwars.Experience || 0 + const hsbwstars = bedwarsLevel(hsbwexp) + const hsbwfk = player.stats?.Bedwars?.final_kills_bedwars || 0 + const hsbwfd = player.stats?.Bedwars?.final_deaths_bedwars || 0 + const hsbwfkdr = hsbwfk / hsbwfd || 0 + const hsbwwins = player.stats.Bedwars.wins_bedwars || 0 - if (player.stats.SkyWars) { - const hsswexp = player.stats?.SkyWars?.skywars_experience || 0 - const hsswstars = skywarsLevel(hsswexp) - const hsswkills = player.stats?.SkyWars?.kills || 0 - const hsswdeaths = player.stats?.SkyWars?.deaths || 0 - const hsswkd = hsswkills / hsswdeaths || 0 - const hsswwins = player.stats?.SkyWars?.wins || 0 + let bwtitle = "" + if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) { + bwtitle = + " This player does not meet the BedWars requirements." + } else { + bwtitle = + " This player meets the BedWars requirements." + } - let swtitle = "" - if (hsswstars < swstars || hsswkd < swkdr) { - swtitle = - " This player does not meet the SkyWars requirements." + statsFields.push({ + name: bwtitle, + value: "**➺ Stars:** `" + + hsbwstars.toFixed(2).toString() + " / " + + bwstars.toString() + "`\n" + + "**➺ FKDR:** `" + + hsbwfkdr.toFixed(2).toString() + + " / " + bwfkdr.toString() + "`\n" + + "**➺ Wins:** `" + + hsbwwins.toString() + " / " + + bwwins.toString() + "`" + }) } else { - swtitle = - " This player meets the SkyWars requirements." + statsFields.push({ + name: " This player never played BedWars.", + value: "**➺ Stats:** `None`" + }) } - statsFields.push({ - name: swtitle, - value: "**➺ Stars:** `" + - hsswstars.toFixed(2).toString() + " / " + - swstars.toString() + "`\n" + - "**➺ KDR:** `" + - hsswkd.toFixed(2).toString() + " / " + - swkdr.toString() + "`\n" + - "**➺ Wins:** `" + - hsswwins.toString() + "`" - }) - } else { - statsFields.push({ - name: " This player never played SkyWars.", - value: "**➺ Stats:** `None`" - }) - } + if (player.stats.SkyWars) { + const hsswexp = player.stats?.SkyWars?.skywars_experience || 0 + const hsswstars = skywarsLevel(hsswexp) + const hsswkills = player.stats?.SkyWars?.kills || 0 + const hsswdeaths = player.stats?.SkyWars?.deaths || 0 + const hsswkd = hsswkills / hsswdeaths || 0 + const hsswwins = player.stats?.SkyWars?.wins || 0 - if (player.stats.Duels) { - const hsduelskills = player.stats?.Duels?.kills || 0 - const hsduelsdeaths = player.stats?.Duels?.deaths || 0 - const hsduelskd = hsduelskills / hsduelsdeaths || 0 - const hsduelswins = player.stats?.Duels?.wins || 0 - const hsduelslosses = player.stats?.Duels?.losses || 0 - const hsduelswlr = hsduelswins / hsduelslosses || 0 + let swtitle = "" + if (hsswstars < swstars || hsswkd < swkdr) { + swtitle = + " This player does not meet the SkyWars requirements." + } else { + swtitle = + " This player meets the SkyWars requirements." + } - let duelstitle = "" - if (hsduelswins < duelswins || hsduelswlr < duelswlr) { - duelstitle = - " This player does not meet the Duels requirements." + statsFields.push({ + name: swtitle, + value: "**➺ Stars:** `" + + hsswstars.toFixed(2).toString() + " / " + + swstars.toString() + "`\n" + + "**➺ KDR:** `" + + hsswkd.toFixed(2).toString() + " / " + + swkdr.toString() + "`\n" + + "**➺ Wins:** `" + + hsswwins.toString() + "`" + }) } else { - duelstitle = - " This player meets the Duels requirements." + statsFields.push({ + name: " This player never played SkyWars.", + value: "**➺ Stats:** `None`" + }) } - statsFields.push({ - name: duelstitle, - value: - "**➺ Wins:** `" + - hsduelswins.toString() + " / " + - duelswins.toString() + "`\n" + - "**➺ WLR:** `" + - hsduelswlr.toFixed(2).toString() + " / " + - duelswlr.toString() + "`\n" + - "**➺ KDR:** `" + - hsduelskd.toFixed(2).toString() + "`\n" - }) - } else { - statsFields.push({ - name: " This player never played Duels.", - value: "**➺ Stats:** `None`" - }) + if (player.stats.Duels) { + const hsduelskills = player.stats?.Duels?.kills || 0 + const hsduelsdeaths = player.stats?.Duels?.deaths || 0 + const hsduelskd = hsduelskills / hsduelsdeaths || 0 + const hsduelswins = player.stats?.Duels?.wins || 0 + const hsduelslosses = player.stats?.Duels?.losses || 0 + const hsduelswlr = hsduelswins / hsduelslosses || 0 + + let duelstitle = "" + if (hsduelswins < duelswins || hsduelswlr < duelswlr) { + duelstitle = + " This player does not meet the Duels requirements." + } else { + duelstitle = + " 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() + "`\n" + }) + } else { + statsFields.push({ + name: " This player never played Duels.", + value: "**➺ Stats:** `None`" + }) + } } // network level - const hypixelExp = player.networkExp + const hypixelExp = player.networkExp || 0 const level = hypixelLevel(hypixelExp) await interaction.editReply({