Skip to content

Commit fab1988

Browse files
committed
Merge branch 'main' into betterLogs
2 parents f618c02 + dcbca75 commit fab1988

File tree

9 files changed

+158
-37
lines changed

9 files changed

+158
-37
lines changed

API/functions/getLatestProfile.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,16 @@ async function getLatestProfile(uuid, options = { museum: false, garden: false }
2323
}
2424
}
2525

26-
const [{ data: playerRes }, { data: profileRes }] = await Promise.all([
27-
axios.get(`https://api.hypixel.net/v2/player?key=${config.minecraft.API.hypixelAPIkey}&uuid=${uuid}`),
26+
const [{ data: profileRes }] = await Promise.all([
2827
axios.get(`https://api.hypixel.net/v2/skyblock/profiles?key=${config.minecraft.API.hypixelAPIkey}&uuid=${uuid}`),
2928
]).catch((error) => {
3029
throw error?.response?.data?.cause ?? "Request to Hypixel API failed. Please try again!";
3130
});
3231

33-
if (playerRes.success === false || profileRes.success === false) {
32+
if (profileRes.success === false) {
3433
throw "Request to Hypixel API failed. Please try again!";
3534
}
3635

37-
if (playerRes.player == null) {
38-
throw "Player not found. It looks like this player has never joined the Hypixel.";
39-
}
40-
4136
if (profileRes.profiles == null || profileRes.profiles.length == 0) {
4237
throw "Player has no SkyBlock profiles.";
4338
}
@@ -57,7 +52,6 @@ async function getLatestProfile(uuid, options = { museum: false, garden: false }
5752
profiles: profileRes.profiles,
5853
profile: profile,
5954
profileData: profileData,
60-
playerRes: playerRes.player,
6155
uuid: uuid,
6256
...(options.museum ? await getMuseum(profileData.profile_id, uuid) : {}),
6357
...(options.garden ? await getGarden(profileData.profile_id) : {}),

API/stats/hotm.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,8 @@ const miningConst = require("../constants/mining.js");
44
const calcSkill = require("../constants/skills.js");
55
const moment = require("moment");
66

7-
module.exports = (player, profile) => {
7+
module.exports = (profile) => {
88
try {
9-
const commissions = {
10-
total: player?.achievements?.skyblock_hard_working_miner ?? 0,
11-
milestone: 0,
12-
};
13-
14-
// CREDITS: https://github.com/SkyCryptWebsite/SkyCrypt/blob/b9842bea6f1494fa2d2fd005b64f57d84646c188/src/stats/mining.js#L129
15-
if (profile.objectives?.tutorial !== undefined) {
16-
for (const key of profile.objectives.tutorial) {
17-
if (key.startsWith("commission_milestone_reward_mining_xp_tier_") === false) {
18-
continue;
19-
}
20-
21-
const tier = parseInt(key.slice(43));
22-
commissions.milestone = Math.max(commissions.milestone, tier);
23-
}
24-
}
25-
269
const forgeItems = [];
2710
if (profile.forge?.forge_processes?.forge_1) {
2811
const forge = Object.values(profile.forge.forge_processes.forge_1);
@@ -80,7 +63,6 @@ module.exports = (player, profile) => {
8063
},
8164
level: calcSkill("hotm", profile?.mining_core?.experience || 0),
8265
ability: titleCase(profile?.mining_core?.selected_pickaxe_ability || "none", true),
83-
commissions: commissions,
8466
forge: forgeItems,
8567
};
8668
} catch (error) {

src/discord/commands/blacklistCommand.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const HypixelDiscordChatBridgeError = require("../../contracts/errorHandler.js");
2+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
23
const { SuccessEmbed } = require("../../contracts/embedHandler.js");
34

45
module.exports = {
@@ -35,13 +36,17 @@ module.exports = {
3536
const name = interaction.options.getString("username");
3637
const arg = interaction.options.getString("arg").toLowerCase();
3738

39+
bot.chat("/lobby megawalls");
40+
await delay(250);
3841
if (arg == "add") {
3942
bot.chat(`/ignore add ${name}`);
4043
} else if (arg == "remove") {
4144
bot.chat(`/ignore remove ${name}`);
4245
} else {
4346
throw new HypixelDiscordChatBridgeError("Invalid Usage: `/ignore [add/remove] [name]`.");
4447
}
48+
await delay(250);
49+
bot.chat("/limbo");
4550

4651
const embed = new SuccessEmbed(
4752
`Successfully ${arg == "add" ? "added" : "removed"} \`${name}\` ${arg == "add" ? "to" : "from"} the blacklist.`,
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const minecraftCommand = require("../../contracts/minecraftCommand.js");
2+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3+
const helperFunctions = require("../../contracts/helperFunctions.js");
4+
5+
class BooCommand extends minecraftCommand {
6+
constructor(minecraft) {
7+
super(minecraft);
8+
9+
this.name = "boo";
10+
this.aliases = [];
11+
this.description = "Boo someone!";
12+
this.options = [
13+
{
14+
name: "username",
15+
description: "User you want to boo!",
16+
required: true,
17+
},
18+
];
19+
this.isOnCooldown = false;
20+
}
21+
22+
async onCommand(username, message) {
23+
try {
24+
if (this.getArgs(message).length === 0) {
25+
// eslint-disable-next-line no-throw-literal
26+
throw "You must provide a user to boo!";
27+
}
28+
29+
if (9 !== new Date().getMonth()) {
30+
// eslint-disable-next-line no-throw-literal
31+
throw "It's not October!";
32+
}
33+
34+
if (this.isOnCooldown) {
35+
return this.send(`/gc ${this.name} Command is on cooldown`);
36+
}
37+
38+
this.send(`/boo ${this.getArgs(message)[0]}`);
39+
await delay(690);
40+
this.send(`/msg ${this.getArgs(message)[0]} ${username} Booed You!`);
41+
await delay(690);
42+
this.send(`/gc Booed ${this.getArgs(message)[0]}!`);
43+
this.isOnCooldown = true;
44+
// CREDITS: @jaxieflaxie for finding this cooldown reset
45+
setTimeout(() => {
46+
bot.chat(
47+
`/w ${
48+
bot.username
49+
} jaxieflaxie is the best wristspasm member! your cool if u see this - ${helperFunctions.generateID(24)}`,
50+
);
51+
setTimeout(() => {
52+
bot.chat(`/w ${bot.username} ${helperFunctions.generateID(48)}`);
53+
this.isOnCooldown = false;
54+
}, 30000);
55+
}, 30000);
56+
this.isOnCooldown = false;
57+
} catch (error) {
58+
this.send(`/gc [ERROR] ${error}`);
59+
}
60+
}
61+
}
62+
63+
module.exports = BooCommand;

src/minecraft/commands/forgeCommand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ForgeCommand extends minecraftCommand {
2727

2828
username = formatUsername(username, data.profileData?.game_mode);
2929

30-
const hotm = getHotm(data.playerRes, data.profile);
30+
const hotm = getHotm(data.profile);
3131

3232
if (hotm == null) {
3333
// eslint-disable-next-line no-throw-literal

src/minecraft/commands/hotmCommand.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class HotmCommand extends minecraftCommand {
2828

2929
username = formatUsername(username, data.profileData?.game_mode);
3030

31-
const hotm = getHotm(data.playerRes, data.profile);
31+
const hotm = getHotm(data.profile);
3232

3333
if (hotm == null) {
3434
// eslint-disable-next-line no-throw-literal
@@ -42,9 +42,7 @@ class HotmCommand extends minecraftCommand {
4242
hotm.powder.gemstone.total,
4343
)} | Mithril Powder: ${formatNumber(hotm.powder.mithril.total)} | Glacite Powder: ${formatNumber(
4444
hotm.powder.glacite.total,
45-
)} | Selected Ability: ${hotm.ability} | Commissions Milestone: ${
46-
hotm.commissions.milestone
47-
} (${hotm.commissions.total.toLocaleString()})`,
45+
)} | Selected Ability: ${hotm.ability}`,
4846
);
4947
} catch (error) {
5048
this.send(`/gc [ERROR] ${error}`);

src/minecraft/commands/skyblockCommand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SkyblockCommand extends minecraftCommand {
4141
}),
4242
getDungeons(data.profile),
4343
getTalismans(data.profile),
44-
getHotm(data.player, data.profile),
44+
getHotm(data.profile),
4545
]);
4646

4747
const skillAverage = (
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const minecraftCommand = require("../../contracts/minecraftCommand.js");
2+
3+
4+
/*
5+
Derpy = 368 mod 24 = 8
6+
Jerry = 376 mod 24 = 16
7+
Scorpius = 384 mod 24 = 0
8+
https://hypixel-skyblock.fandom.com/wiki/Mayor_Election#Special_Candidates_Election_Cycle
9+
*/
10+
11+
const hourMs = 50000;
12+
const dayMs = 24 * hourMs;
13+
const monthLength = 31;
14+
const yearLength = 12;
15+
16+
const monthMs = monthLength * dayMs;
17+
const yearMs = yearLength * monthMs;
18+
19+
const yearZero = 1560275700000;
20+
21+
const currentSkyblockYear = timeToSkyblockYear(Date.now());
22+
23+
var yearsUntilSpecial = 0;
24+
var diffSkyblockYear = currentSkyblockYear;
25+
var specialMayor = "";
26+
27+
28+
function timeToSkyblockYear(time) {
29+
return Math.floor((time - yearZero) / yearMs) + 1;
30+
}
31+
32+
function getSpecialMayor(skyblockYear) {
33+
if (diffSkyblockYear % 24 == 8){
34+
specialMayor = "Derpy";
35+
} else if (diffSkyblockYear % 24 == 16){
36+
specialMayor = "Jerry";
37+
} else if (diffSkyblockYear % 24 == 0){
38+
specialMayor = "Scorpius";
39+
} else {
40+
specialMayor = "Error!";
41+
}
42+
return specialMayor;
43+
}
44+
45+
class SpecialMayorCommand extends minecraftCommand {
46+
constructor(minecraft) {
47+
super(minecraft);
48+
49+
this.name = "specialmayor";
50+
this.aliases = ["specmayor"];
51+
this.description = "How many years until next special mayor, along with speculated special mayor.";
52+
this.options = [];
53+
}
54+
55+
async onCommand() {
56+
try {
57+
58+
if (currentSkyblockYear % 8 == 0){
59+
specialMayor = getSpecialMayor(currentSkyblockYear);
60+
this.send(`/gc Special Mayor this year! It is speculated to be ${specialMayor}.`);
61+
} else {
62+
while (diffSkyblockYear % 8 != 0){
63+
yearsUntilSpecial += 1;
64+
diffSkyblockYear += 1;
65+
specialMayor = getSpecialMayor(diffSkyblockYear);
66+
}
67+
this.send(`/gc Not Special Mayor, ${yearsUntilSpecial} years until the next one! It is speculated to be ${specialMayor}.`);
68+
}
69+
70+
} catch (error) {
71+
console.log(error)
72+
this.send(`/gc [ERROR] ${error}`);
73+
}
74+
}
75+
}
76+
77+
module.exports = SpecialMayorCommand;
78+

src/minecraft/handlers/ChatHandler.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,16 +848,17 @@ class StateHandler extends eventHandler {
848848

849849
isAlreadyBlacklistedMessage(message) {
850850
return (
851-
message.includes(`You've already ignored that player! /ignore remove Player to unignore them!`) &&
851+
message.includes(`You've already blocked that player! /block remove <player> to unblock them!`) &&
852852
!message.includes(":")
853853
);
854854
}
855+
855856
isBlacklistRemovedMessage(message) {
856-
return message.startsWith("Removed") && message.includes("from your ignore list.") && !message.includes(":");
857+
return message.startsWith("Unblocked") && message.endsWith(".") && !message.includes(":");
857858
}
858859

859860
isBlacklistMessage(message) {
860-
return message.startsWith("Added") && message.includes("to your ignore list.") && !message.includes(":");
861+
return message.startsWith("Blocked") && message.endsWith(".") && !message.includes(":");
861862
}
862863

863864
isGuildMessage(message) {
@@ -1082,7 +1083,7 @@ class StateHandler extends eventHandler {
10821083
return;
10831084
}
10841085

1085-
const linkedUser = Object.values(linked).find((u) => player)
1086+
const linkedUser = Object.values(linked).find((u) => player);
10861087
if (linkedUser === undefined) {
10871088
return;
10881089
}

0 commit comments

Comments
 (0)