Skip to content

Commit

Permalink
Merge branch 'main' into quickSetup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Oct 19, 2024
2 parents 3dc75f7 + 26cb9c7 commit 5ce9349
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 26 deletions.
2 changes: 1 addition & 1 deletion API/stats/talismans.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions src/discord/commands/forceUpdateEveryone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});

Expand All @@ -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",
});

Expand All @@ -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",
});

Expand All @@ -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",
});

Expand Down
6 changes: 3 additions & 3 deletions src/discord/commands/linkedCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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",
});

Expand All @@ -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",
});

Expand Down
4 changes: 2 additions & 2 deletions src/discord/commands/unverifyCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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",
});

Expand Down
4 changes: 2 additions & 2 deletions src/discord/commands/updateCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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",
});

Expand Down
8 changes: 4 additions & 4 deletions src/discord/commands/verifyCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});

Expand Down Expand Up @@ -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",
});

Expand All @@ -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 });
}
}
},
Expand Down
41 changes: 41 additions & 0 deletions src/minecraft/commands/PlayerCommand.js
Original file line number Diff line number Diff line change
@@ -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;
31 changes: 21 additions & 10 deletions src/minecraft/commands/personalBestCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)}`);
}
Expand Down

0 comments on commit 5ce9349

Please sign in to comment.