From 7fd3ee72be2c19a32bdc71d01692379a95abe58d Mon Sep 17 00:00:00 2001 From: Jacob <55346310+Kathund@users.noreply.github.com> Date: Fri, 27 Sep 2024 03:37:19 +0800 Subject: [PATCH 1/4] Fix Personal Best (#281) --- src/minecraft/commands/personalBestCommand.js | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/minecraft/commands/personalBestCommand.js b/src/minecraft/commands/personalBestCommand.js index 148bbb52..e491e90d 100644 --- a/src/minecraft/commands/personalBestCommand.js +++ b/src/minecraft/commands/personalBestCommand.js @@ -29,6 +29,16 @@ class PersonalBestCommand extends minecraftCommand { username = this.getArgs(message)[0] || username; const floor = (this.getArgs(message)[1] ?? "M7").toLowerCase(); const rank = (this.getArgs(message)[2] ?? "S+").toLowerCase(); + const floors = ["e", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "m1", "m2", "m3", "m4", "m5", "m6", "m7"]; + const ranks = ["", "s", "s+"]; + if (floors.includes(floor) === false) { + // eslint-disable-next-line no-throw-literal + throw "Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]"; + } + if (ranks.includes(rank) === false) { + // eslint-disable-next-line no-throw-literal + throw "Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]"; + } const data = await getLatestProfile(username); @@ -41,41 +51,42 @@ class PersonalBestCommand extends minecraftCommand { throw `${username} has never played dungeons on ${data.profileData.cute_name}.`; } - let requested_floor = dungeons.catacombs; + let requested_floor = null; let time = 0; const floor_type = floor.charAt(floor.length - 2); const floor_number = floor.charAt(floor.length - 1); switch (floor_type) { case "m": - requested_floor = dungeons.catacombs?.MASTER_MODE_FLOORS?.[`floor_${floor_number}`] ?? null; + requested_floor = dungeons.catacombs?.MASTER_MODE_FLOORS?.[`floor_${floor_number}`] || null; break; case "f": - requested_floor = dungeons.catacombs?.floors?.[`floor_${floor_number}`] ?? null; + requested_floor = dungeons.catacombs?.floors?.[`floor_${floor_number}`] || null; break; case "e": - requested_floor = dungeons.catacombs?.floors?.entrance ?? null; + requested_floor = dungeons.catacombs?.floors?.entrance || null; break; default: - this.send("/gc Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]"); - break; + // eslint-disable-next-line no-throw-literal + throw "Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]"; } // eslint-disable-next-line no-throw-literal if (requested_floor === null) throw `${username} has never gotten a ${rank} on ${floor} before.`; switch (rank) { case "s+": - time = requested_floor.fastest_s_plus; + time = requested_floor?.fastest_s_plus || 0; break; case "s": - time = requested_floor.fastest_s; + time = requested_floor?.fastest_s || 0; break; default: - this.send("/gc Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]"); + time = requested_floor?.fastest || 0; break; } if (time === 0) { - this.send(`/gc ${username} has no PB on ${floor} ${rank}`); + // eslint-disable-next-line no-throw-literal + throw `${username} has no PB on ${floor} ${rank}`; } else { this.send(`/gc ${username}'s PB on ${floor} with ${rank} rank is ${millisToMinutesAndSeconds(time)}`); } From 975b7cb4b25c2a9ea05e571c4af206faa64b3df4 Mon Sep 17 00:00:00 2001 From: Jacob <55346310+Kathund@users.noreply.github.com> Date: Fri, 27 Sep 2024 03:37:50 +0800 Subject: [PATCH 2/4] Update Credits (#280) --- src/discord/commands/forceUpdateEveryone.js | 8 ++++---- src/discord/commands/linkedCommand.js | 6 +++--- src/discord/commands/unverifyCommand.js | 4 ++-- src/discord/commands/updateCommand.js | 4 ++-- src/discord/commands/verifyCommand.js | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/discord/commands/forceUpdateEveryone.js b/src/discord/commands/forceUpdateEveryone.js index b39cbdea..ac11be4d 100644 --- a/src/discord/commands/forceUpdateEveryone.js +++ b/src/discord/commands/forceUpdateEveryone.js @@ -33,7 +33,7 @@ module.exports = { .setTitle("Updating Users") .setDescription(`Progress: 0 / ${Object.keys(linked).length} (\`0%\`)`) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); @@ -59,7 +59,7 @@ module.exports = { `Progress: ${Object.keys(linked).indexOf(id)} / ${Object.keys(linked).length} (\`${((Object.keys(linked).indexOf(id) / Object.keys(linked).length) * 100).toFixed(2)}%\`)`, ) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); @@ -81,7 +81,7 @@ module.exports = { .setTitle("Users Updated") .setDescription(description.join("\n")) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); @@ -93,7 +93,7 @@ module.exports = { .setAuthor({ name: "An Error has occurred" }) .setDescription(`\`\`\`${error}\`\`\``) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); diff --git a/src/discord/commands/linkedCommand.js b/src/discord/commands/linkedCommand.js index 3961ce5b..c7814a48 100644 --- a/src/discord/commands/linkedCommand.js +++ b/src/discord/commands/linkedCommand.js @@ -52,7 +52,7 @@ module.exports = { const username = await getUsername(uuid); const embed = new SuccessEmbed(`<@${user.id}> is linked to \`${username}\` (\`${uuid}\`).`, { - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); await interaction.followUp({ embeds: [embed], ephemeral: true }); @@ -68,7 +68,7 @@ module.exports = { } const embed = new SuccessEmbed(`\`${name}\` (\`${uuid}\`) is linked to <@${discordID}>.`, { - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); @@ -82,7 +82,7 @@ module.exports = { .setAuthor({ name: "An Error has occurred" }) .setDescription(`\`\`\`${error}\`\`\``) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); diff --git a/src/discord/commands/unverifyCommand.js b/src/discord/commands/unverifyCommand.js index 3b646ad1..065e1ce6 100644 --- a/src/discord/commands/unverifyCommand.js +++ b/src/discord/commands/unverifyCommand.js @@ -33,7 +33,7 @@ module.exports = { const updateRole = new SuccessEmbed( `You have successfully unlinked \`${await getUsername(uuid)}\`. Run \`/verify\` to link a new account.`, - { text: `by @kathund. | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" }, + { text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" }, ); await interaction.followUp({ embeds: [updateRole] }); } catch (error) { @@ -42,7 +42,7 @@ module.exports = { .setAuthor({ name: "An Error has occurred" }) .setDescription(`\`\`\`${error}\`\`\``) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); diff --git a/src/discord/commands/updateCommand.js b/src/discord/commands/updateCommand.js index 4745aeff..41da8efd 100644 --- a/src/discord/commands/updateCommand.js +++ b/src/discord/commands/updateCommand.js @@ -154,7 +154,7 @@ module.exports = { const updateRole = new SuccessEmbed( `<@${interaction.user.id}>'s roles have been successfully synced with \`${player.nickname ?? "Unknown"}\`!`, - { text: `by @kathund. | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" }, + { text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" }, ); await interaction.followUp({ embeds: [updateRole], ephemeral: true }); @@ -164,7 +164,7 @@ module.exports = { .setAuthor({ name: "An Error has occurred" }) .setDescription(`\`\`\`${error}\`\`\``) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); diff --git a/src/discord/commands/verifyCommand.js b/src/discord/commands/verifyCommand.js index 4adae6e3..86cb2ba2 100644 --- a/src/discord/commands/verifyCommand.js +++ b/src/discord/commands/verifyCommand.js @@ -81,7 +81,7 @@ module.exports = { .setAuthor({ name: "Successfully linked!" }) .setDescription(`${user ? `<@${user.id}>'s` : "Your"} account has been successfully linked to \`${nickname}\``) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); @@ -109,7 +109,7 @@ module.exports = { .setAuthor({ name: "An Error has occurred" }) .setDescription(`\`\`\`${error}\`\`\``) .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); @@ -129,11 +129,11 @@ module.exports = { ) .setImage("https://media.discordapp.net/attachments/922202066653417512/1066476136953036800/tutorial.gif") .setFooter({ - text: `by @kathund. | /help [command] for more information`, + text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png", }); - await interaction.followUp({ embeds: [verificationTutorialEmbed], ephemeral: true }); + await interaction.followUp({ embeds: [verificationTutorialEmbed], ephemeral: true }); } } }, From 718d31f37780bbe5abaaae1298a14ce17a3bad44 Mon Sep 17 00:00:00 2001 From: Jacob <55346310+Kathund@users.noreply.github.com> Date: Sat, 5 Oct 2024 18:04:56 +0800 Subject: [PATCH 3/4] Player Command (#278) --- src/minecraft/commands/PlayerCommand.js | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/minecraft/commands/PlayerCommand.js diff --git a/src/minecraft/commands/PlayerCommand.js b/src/minecraft/commands/PlayerCommand.js new file mode 100644 index 00000000..9e7f8a8a --- /dev/null +++ b/src/minecraft/commands/PlayerCommand.js @@ -0,0 +1,41 @@ +const minecraftCommand = require("../../contracts/minecraftCommand.js"); +const { formatNumber } = require("../../contracts/helperFunctions.js"); +const hypixel = require("../../contracts/API/HypixelRebornAPI.js"); + +class PlayerCommand extends minecraftCommand { + constructor(minecraft) { + super(minecraft); + + this.name = "player"; + this.aliases = []; + this.description = "Get Hypixel Player Stats"; + this.options = [ + { + name: "username", + description: "Minecraft username", + required: false, + }, + ]; + } + + async onCommand(username, message) { + try { + // CREDITS: by @Kathund (https://github.com/Kathund) + username = this.getArgs(message)[0] || username; + const { achievementPoints, nickname, rank, karma, level, guild } = await hypixel.getPlayer(username, { + guild: true, + }); + const guildName = guild ? guild.name : "None"; + + this.send( + `/gc ${rank !== "Default" ? `[${rank}] ` : ""}${nickname}'s level: ${level} | Karma: ${formatNumber(karma, 0)} Achievement Points: ${formatNumber(achievementPoints, 0)} Guild: ${guildName} `, + ); + } catch (error) { + console.log(error); + + this.send(`/gc [ERROR] ${error}`); + } + } +} + +module.exports = PlayerCommand; From 26cb9c7789824802acdd7448c5e03539e758cc68 Mon Sep 17 00:00:00 2001 From: Jacob <55346310+Kathund@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:38:29 +0800 Subject: [PATCH 4/4] Fix talismans when player has never gone to rift (#282) --- API/stats/talismans.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API/stats/talismans.js b/API/stats/talismans.js index c492e5aa..8bd17d6e 100644 --- a/API/stats/talismans.js +++ b/API/stats/talismans.js @@ -66,7 +66,7 @@ module.exports = async (profile) => { output.enriched++; } } - if(profile.rift.access.consumed_prism === true) { + if (profile?.rift?.access?.consumed_prism === true) { output.magicPower += 11 }