Skip to content

Commit ee0e0d3

Browse files
committed
Merge branch 'main' into betterLogs
2 parents 5449a15 + 26cb9c7 commit ee0e0d3

File tree

8 files changed

+77
-25
lines changed

8 files changed

+77
-25
lines changed

API/stats/talismans.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = async (profile) => {
6767
output.enriched++;
6868
}
6969
}
70-
if(profile.rift.access.consumed_prism === true) {
70+
if (profile?.rift?.access?.consumed_prism === true) {
7171
output.magicPower += 11
7272
}
7373

src/discord/commands/forceUpdateEveryone.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
.setTitle("Updating Users")
3434
.setDescription(`Progress: 0 / ${Object.keys(linked).length} (\`0%\`)`)
3535
.setFooter({
36-
text: `by @kathund. | /help [command] for more information`,
36+
text: `by @.kathund | /help [command] for more information`,
3737
iconURL: "https://i.imgur.com/uUuZx2E.png",
3838
});
3939

@@ -59,7 +59,7 @@ module.exports = {
5959
`Progress: ${Object.keys(linked).indexOf(id)} / ${Object.keys(linked).length} (\`${((Object.keys(linked).indexOf(id) / Object.keys(linked).length) * 100).toFixed(2)}%\`)`,
6060
)
6161
.setFooter({
62-
text: `by @kathund. | /help [command] for more information`,
62+
text: `by @.kathund | /help [command] for more information`,
6363
iconURL: "https://i.imgur.com/uUuZx2E.png",
6464
});
6565

@@ -81,7 +81,7 @@ module.exports = {
8181
.setTitle("Users Updated")
8282
.setDescription(description.join("\n"))
8383
.setFooter({
84-
text: `by @kathund. | /help [command] for more information`,
84+
text: `by @.kathund | /help [command] for more information`,
8585
iconURL: "https://i.imgur.com/uUuZx2E.png",
8686
});
8787

@@ -93,7 +93,7 @@ module.exports = {
9393
.setAuthor({ name: "An Error has occurred" })
9494
.setDescription(`\`\`\`${error}\`\`\``)
9595
.setFooter({
96-
text: `by @kathund. | /help [command] for more information`,
96+
text: `by @.kathund | /help [command] for more information`,
9797
iconURL: "https://i.imgur.com/uUuZx2E.png",
9898
});
9999

src/discord/commands/linkedCommand.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = {
5252

5353
const username = await getUsername(uuid);
5454
const embed = new SuccessEmbed(`<@${user.id}> is linked to \`${username}\` (\`${uuid}\`).`, {
55-
text: `by @kathund. | /help [command] for more information`,
55+
text: `by @.kathund | /help [command] for more information`,
5656
iconURL: "https://i.imgur.com/uUuZx2E.png",
5757
});
5858
await interaction.followUp({ embeds: [embed], ephemeral: true });
@@ -68,7 +68,7 @@ module.exports = {
6868
}
6969

7070
const embed = new SuccessEmbed(`\`${name}\` (\`${uuid}\`) is linked to <@${discordID}>.`, {
71-
text: `by @kathund. | /help [command] for more information`,
71+
text: `by @.kathund | /help [command] for more information`,
7272
iconURL: "https://i.imgur.com/uUuZx2E.png",
7373
});
7474

@@ -82,7 +82,7 @@ module.exports = {
8282
.setAuthor({ name: "An Error has occurred" })
8383
.setDescription(`\`\`\`${error}\`\`\``)
8484
.setFooter({
85-
text: `by @kathund. | /help [command] for more information`,
85+
text: `by @.kathund | /help [command] for more information`,
8686
iconURL: "https://i.imgur.com/uUuZx2E.png",
8787
});
8888

src/discord/commands/unverifyCommand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333

3434
const updateRole = new SuccessEmbed(
3535
`You have successfully unlinked \`${await getUsername(uuid)}\`. Run \`/verify\` to link a new account.`,
36-
{ text: `by @kathund. | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" },
36+
{ text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" },
3737
);
3838
await interaction.followUp({ embeds: [updateRole] });
3939
} catch (error) {
@@ -42,7 +42,7 @@ module.exports = {
4242
.setAuthor({ name: "An Error has occurred" })
4343
.setDescription(`\`\`\`${error}\`\`\``)
4444
.setFooter({
45-
text: `by @kathund. | /help [command] for more information`,
45+
text: `by @.kathund | /help [command] for more information`,
4646
iconURL: "https://i.imgur.com/uUuZx2E.png",
4747
});
4848

src/discord/commands/updateCommand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ module.exports = {
154154

155155
const updateRole = new SuccessEmbed(
156156
`<@${interaction.user.id}>'s roles have been successfully synced with \`${player.nickname ?? "Unknown"}\`!`,
157-
{ text: `by @kathund. | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" },
157+
{ text: `by @.kathund | /help [command] for more information`, iconURL: "https://i.imgur.com/uUuZx2E.png" },
158158
);
159159

160160
await interaction.followUp({ embeds: [updateRole], ephemeral: true });
@@ -164,7 +164,7 @@ module.exports = {
164164
.setAuthor({ name: "An Error has occurred" })
165165
.setDescription(`\`\`\`${error}\`\`\``)
166166
.setFooter({
167-
text: `by @kathund. | /help [command] for more information`,
167+
text: `by @.kathund | /help [command] for more information`,
168168
iconURL: "https://i.imgur.com/uUuZx2E.png",
169169
});
170170

src/discord/commands/verifyCommand.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = {
8282
.setAuthor({ name: "Successfully linked!" })
8383
.setDescription(`${user ? `<@${user.id}>'s` : "Your"} account has been successfully linked to \`${nickname}\``)
8484
.setFooter({
85-
text: `by @kathund. | /help [command] for more information`,
85+
text: `by @.kathund | /help [command] for more information`,
8686
iconURL: "https://i.imgur.com/uUuZx2E.png",
8787
});
8888

@@ -110,7 +110,7 @@ module.exports = {
110110
.setAuthor({ name: "An Error has occurred" })
111111
.setDescription(`\`\`\`${error}\`\`\``)
112112
.setFooter({
113-
text: `by @kathund. | /help [command] for more information`,
113+
text: `by @.kathund | /help [command] for more information`,
114114
iconURL: "https://i.imgur.com/uUuZx2E.png",
115115
});
116116

@@ -130,7 +130,7 @@ module.exports = {
130130
)
131131
.setImage("https://media.discordapp.net/attachments/922202066653417512/1066476136953036800/tutorial.gif")
132132
.setFooter({
133-
text: `by @kathund. | /help [command] for more information`,
133+
text: `by @.kathund | /help [command] for more information`,
134134
iconURL: "https://i.imgur.com/uUuZx2E.png",
135135
});
136136

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const minecraftCommand = require("../../contracts/minecraftCommand.js");
2+
const { formatNumber } = require("../../contracts/helperFunctions.js");
3+
const hypixel = require("../../contracts/API/HypixelRebornAPI.js");
4+
5+
class PlayerCommand extends minecraftCommand {
6+
constructor(minecraft) {
7+
super(minecraft);
8+
9+
this.name = "player";
10+
this.aliases = [];
11+
this.description = "Get Hypixel Player Stats";
12+
this.options = [
13+
{
14+
name: "username",
15+
description: "Minecraft username",
16+
required: false,
17+
},
18+
];
19+
}
20+
21+
async onCommand(username, message) {
22+
try {
23+
// CREDITS: by @Kathund (https://github.com/Kathund)
24+
username = this.getArgs(message)[0] || username;
25+
const { achievementPoints, nickname, rank, karma, level, guild } = await hypixel.getPlayer(username, {
26+
guild: true,
27+
});
28+
const guildName = guild ? guild.name : "None";
29+
30+
this.send(
31+
`/gc ${rank !== "Default" ? `[${rank}] ` : ""}${nickname}'s level: ${level} | Karma: ${formatNumber(karma, 0)} Achievement Points: ${formatNumber(achievementPoints, 0)} Guild: ${guildName} `,
32+
);
33+
} catch (error) {
34+
console.log(error);
35+
36+
this.send(`/gc [ERROR] ${error}`);
37+
}
38+
}
39+
}
40+
41+
module.exports = PlayerCommand;

src/minecraft/commands/personalBestCommand.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ class PersonalBestCommand extends minecraftCommand {
3030
username = this.getArgs(message)[0] || username;
3131
const floor = (this.getArgs(message)[1] ?? "M7").toLowerCase();
3232
const rank = (this.getArgs(message)[2] ?? "S+").toLowerCase();
33+
const floors = ["e", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "m1", "m2", "m3", "m4", "m5", "m6", "m7"];
34+
const ranks = ["", "s", "s+"];
35+
if (floors.includes(floor) === false) {
36+
// eslint-disable-next-line no-throw-literal
37+
throw "Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]";
38+
}
39+
if (ranks.includes(rank) === false) {
40+
// eslint-disable-next-line no-throw-literal
41+
throw "Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]";
42+
}
3343

3444
const data = await getLatestProfile(username);
3545

@@ -42,41 +52,42 @@ class PersonalBestCommand extends minecraftCommand {
4252
throw `${username} has never played dungeons on ${data.profileData.cute_name}.`;
4353
}
4454

45-
let requested_floor = dungeons.catacombs;
55+
let requested_floor = null;
4656
let time = 0;
4757
const floor_type = floor.charAt(floor.length - 2);
4858
const floor_number = floor.charAt(floor.length - 1);
4959
switch (floor_type) {
5060
case "m":
51-
requested_floor = dungeons.catacombs?.MASTER_MODE_FLOORS?.[`floor_${floor_number}`] ?? null;
61+
requested_floor = dungeons.catacombs?.MASTER_MODE_FLOORS?.[`floor_${floor_number}`] || null;
5262
break;
5363
case "f":
54-
requested_floor = dungeons.catacombs?.floors?.[`floor_${floor_number}`] ?? null;
64+
requested_floor = dungeons.catacombs?.floors?.[`floor_${floor_number}`] || null;
5565
break;
5666
case "e":
57-
requested_floor = dungeons.catacombs?.floors?.entrance ?? null;
67+
requested_floor = dungeons.catacombs?.floors?.entrance || null;
5868
break;
5969
default:
60-
this.send("/gc Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]");
61-
break;
70+
// eslint-disable-next-line no-throw-literal
71+
throw "Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]";
6272
}
6373
// eslint-disable-next-line no-throw-literal
6474
if (requested_floor === null) throw `${username} has never gotten a ${rank} on ${floor} before.`;
6575

6676
switch (rank) {
6777
case "s+":
68-
time = requested_floor.fastest_s_plus;
78+
time = requested_floor?.fastest_s_plus || 0;
6979
break;
7080
case "s":
71-
time = requested_floor.fastest_s;
81+
time = requested_floor?.fastest_s || 0;
7282
break;
7383
default:
74-
this.send("/gc Invalid Usage: !pb [user] [floor (m7/f4/etc)] [rank (S+, S, any)]");
84+
time = requested_floor?.fastest || 0;
7585
break;
7686
}
7787

7888
if (time === 0) {
79-
this.send(`/gc ${username} has no PB on ${floor} ${rank}`);
89+
// eslint-disable-next-line no-throw-literal
90+
throw `${username} has no PB on ${floor} ${rank}`;
8091
} else {
8192
this.send(`/gc ${username}'s PB on ${floor} with ${rank} rank is ${millisToMinutesAndSeconds(time)}`);
8293
}

0 commit comments

Comments
 (0)