Skip to content

Commit 39c2211

Browse files
authored
Officer Commands (#263)
* Officer Commands * Add missing commands * Rewrite Officer Commands * Remove old /gc
1 parent d9fc8d7 commit 39c2211

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+197
-189
lines changed

src/contracts/minecraftCommand.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const config = require("../../config.json");
55
class minecraftCommand {
66
constructor(minecraft) {
77
this.minecraft = minecraft;
8+
this.officer = false;
89
}
910

1011
getArgs(message) {
@@ -29,11 +30,11 @@ class minecraftCommand {
2930
n++;
3031

3132
if (n >= 5) {
32-
return this.send("/gc Command failed to send message after 5 attempts. Please try again later.");
33+
return this.send("Command failed to send message after 5 attempts. Please try again later.");
3334
}
3435

3536
await delay(250);
36-
return this.send(message);
37+
return this.send(`${message}`);
3738
} else if (
3839
msg.toString().includes("You cannot say the same message twice!") === true &&
3940
msg.toString().includes(":") === false
@@ -42,7 +43,7 @@ class minecraftCommand {
4243
n++;
4344

4445
if (n >= 5) {
45-
return this.send("/gc Command failed to send message after 5 attempts. Please try again later.");
46+
return this.send(`Command failed to send message after 5 attempts. Please try again later.`);
4647
}
4748

4849
await delay(250);
@@ -54,7 +55,7 @@ class minecraftCommand {
5455
};
5556

5657
bot.once("message", listener);
57-
bot.chat(message);
58+
bot.chat(`/${this.officer ? "oc" : "gc"} ${message}`);
5859

5960
setTimeout(() => {
6061
bot.removeListener("message", listener);

src/minecraft/CommandHandler.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CommandHandler {
1919
}
2020
}
2121

22-
handle(player, message) {
22+
handle(player, message, officer) {
2323
if (message.startsWith(this.prefix)) {
2424
if (config.minecraft.commands.normal === false) {
2525
return;
@@ -34,6 +34,7 @@ class CommandHandler {
3434
return;
3535
}
3636

37+
command.officer = officer;
3738
Logger.minecraftMessage(`${player} - [${command.name}] ${message}`);
3839
command.onCommand(player, message);
3940
} else if (message.startsWith("-") && message.startsWith("- ") === false) {
@@ -46,7 +47,7 @@ class CommandHandler {
4647
return;
4748
}
4849

49-
bot.chat(`/gc [SOOPY V2] ${message}`);
50+
bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] ${message}`);
5051

5152
Logger.minecraftMessage(`${player} - [${command}] ${message}`);
5253

@@ -56,12 +57,12 @@ class CommandHandler {
5657
const response = await axios.get(URI);
5758

5859
if (response?.data?.msg === undefined) {
59-
return bot.chat(`/gc [SOOPY V2] An error occured while running the command`);
60+
return bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] An error occured while running the command`);
6061
}
6162

62-
bot.chat(`/gc [SOOPY V2] ${response.data.msg}`);
63+
bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] ${response.data.msg}`);
6364
} catch (e) {
64-
bot.chat(`/gc [SOOPY V2] ${e.cause ?? e.message ?? "Unknown error"}`);
65+
bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] ${e.cause ?? e.message ?? "Unknown error"}`);
6566
}
6667
})();
6768
}

src/minecraft/commands/8ballCommand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class EightBallCommand extends minecraftCommand {
2626

2727
const { data } = await axios.get(`https://www.eightballapi.com/api`);
2828

29-
this.send(`/gc ${data.reading}`);
29+
this.send(`${data.reading}`);
3030
} catch (error) {
31-
this.send(`/gc [ERROR] ${error}`);
31+
this.send(`[ERROR] ${error}`);
3232
}
3333
}
3434
}

src/minecraft/commands/PlayerCommand.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ class PlayerCommand extends minecraftCommand {
2828
const guildName = guild ? guild.name : "None";
2929

3030
this.send(
31-
`/gc ${rank !== "Default" ? `[${rank}] ` : ""}${nickname}'s level: ${level} | Karma: ${formatNumber(karma, 0)} Achievement Points: ${formatNumber(achievementPoints, 0)} Guild: ${guildName} `
31+
`${rank !== "Default" ? `[${rank}] ` : ""}${nickname}'s level: ${level} | Karma: ${formatNumber(karma, 0)} Achievement Points: ${formatNumber(achievementPoints, 0)} Guild: ${guildName} `
3232
);
3333
} catch (error) {
3434
console.log(error);
35-
36-
this.send(`/gc [ERROR] ${error}`);
35+
this.send(`[ERROR] ${error}`);
3736
}
3837
}
3938
}

src/minecraft/commands/UHCStatsCommmand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ class UHCStatsCommand extends minecraftCommand {
2525

2626
const { starLevel, KDRatio, wins, headsEaten } = player.stats.uhc;
2727

28-
this.send(`/gc [${starLevel}✫] ${player.nickname} | KDR: ${KDRatio} | W: ${wins} | Heads: ${headsEaten}`);
28+
this.send(`[${starLevel}✫] ${player.nickname} | KDR: ${KDRatio} | W: ${wins} | Heads: ${headsEaten}`);
2929
} catch (error) {
3030
this.send(
31-
`/gc ${error
31+
`${error
3232
.toString()
3333
.replace("[hypixel-api-reborn] ", "")
3434
.replace("For help join our Discord Server https://discord.gg/NSEBNMM", "")

src/minecraft/commands/accessoriesCommand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ class AccessoriesCommand extends minecraftCommand {
4747
.join(", ");
4848

4949
this.send(
50-
`/gc ${username}'s Accessories: ${talismans?.total ?? 0} (${rarities}), Recombed: ${
50+
`${username}'s Accessories: ${talismans?.total ?? 0} (${rarities}), Recombed: ${
5151
talismans?.recombed ?? 0
5252
}, Enriched: ${talismans?.enriched ?? 0} | Reforge: ${talismans.power} | Magic Power: ${talismans.magicPower}`
5353
);
5454
} catch (error) {
55-
this.send(`/gc [ERROR] ${error}`);
55+
this.send(`[ERROR] ${error}`);
5656
}
5757
}
5858
}

src/minecraft/commands/auctionHouseCommand.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AuctionHouseCommand extends minecraftCommand {
4141
const player = playerResponse.data?.player || {};
4242

4343
if (auctions.length === 0) {
44-
return this.send(`/gc This player has no active auctions.`);
44+
return this.send("This player has no active auctions.");
4545
}
4646

4747
const activeAuctions = auctions.filter((auction) => auction.end >= Date.now());
@@ -91,10 +91,10 @@ class AuctionHouseCommand extends minecraftCommand {
9191
}
9292

9393
imgurUrl = string;
94-
this.send(`/gc ${username}'s Active Auctions: Check Discord Bridge for image.`);
94+
this.send(`${username}'s Active Auctions: Check Discord Bridge for image.`);
9595
} catch (error) {
9696
console.log(error);
97-
this.send(`/gc [ERROR] ${error}`);
97+
this.send(`[ERROR] ${error}`);
9898
}
9999
}
100100
}

src/minecraft/commands/bedwarsStatsCommand.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BedwarsCommand extends minecraftCommand {
3333
const { broken, BLRatio } = player.stats.bedwars.beds;
3434

3535
this.send(
36-
`/gc [${level}✫] ${player.nickname} FK: ${formatNumber(finalKills)} FKDR: ${finalKDRatio} W: ${formatNumber(
36+
`[${level}✫] ${player.nickname} FK: ${formatNumber(finalKills)} FKDR: ${finalKDRatio} W: ${formatNumber(
3737
wins
3838
)} WLR: ${WLRatio} BB: ${formatNumber(broken)} BLR: ${BLRatio} WS: ${winstreak}`
3939
);
@@ -43,18 +43,18 @@ class BedwarsCommand extends minecraftCommand {
4343
const { broken, BLRatio } = player.stats.bedwars[mode].beds;
4444

4545
this.send(
46-
`/gc [${level}✫] ${player.nickname} ${capitalize(mode)} FK: ${formatNumber(
46+
`[${level}✫] ${player.nickname} ${capitalize(mode)} FK: ${formatNumber(
4747
finalKills
4848
)} FKDR: ${finalKDRatio} Wins: ${formatNumber(wins)} WLR: ${WLRatio} BB: ${formatNumber(
4949
broken
5050
)} BLR: ${BLRatio} WS: ${winstreak}`
5151
);
5252
} else {
53-
this.send("/gc Invalid mode. Valid modes: overall, solo, doubles, threes, fours, 4v4");
53+
this.send("Invalid mode. Valid modes: overall, solo, doubles, threes, fours, 4v4");
5454
}
5555
} catch (error) {
5656
this.send(
57-
`/gc ${error
57+
`${error
5858
.toString()
5959
.replace("[hypixel-api-reborn] ", "")
6060
.replace("For help join our Discord Server https://discord.gg/NSEBNMM", "")

src/minecraft/commands/bestiaryCommand.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { formatUsername } = require("../../contracts/helperFunctions.js");
33
const minecraftCommand = require("../../contracts/minecraftCommand.js");
44
const { getBestiary } = require("../../../API/stats/bestiary.js");
55

6-
class EightBallCommand extends minecraftCommand {
6+
class BestiaryCommand extends minecraftCommand {
77
constructor(minecraft) {
88
super(minecraft);
99

@@ -33,15 +33,15 @@ class EightBallCommand extends minecraftCommand {
3333

3434
const bestiary = getBestiary(data.profile);
3535
if (bestiary === null) {
36-
return this.send(`/gc This player has not yet joined SkyBlock since the bestiary update.`);
36+
return this.send("This player has not yet joined SkyBlock since the bestiary update.");
3737
}
3838

3939
if (mob) {
4040
const mobData = this.getBestiaryObject(bestiary).find((m) => m.name.toLowerCase().includes(mob.toLowerCase()));
4141

4242
if (mobData) {
4343
this.send(
44-
`/gc ${username}'s ${mobData.name} Bestiary: ${mobData.kills} / ${mobData.nextTierKills} (${
44+
`${username}'s ${mobData.name} Bestiary: ${mobData.kills} / ${mobData.nextTierKills} (${
4545
mobData.nextTierKills - mobData.kills
4646
}) `
4747
);
@@ -51,7 +51,7 @@ class EightBallCommand extends minecraftCommand {
5151
}
5252

5353
this.send(
54-
`/gc ${username}'s Bestiary Milestone: ${bestiary.milestone} / ${bestiary.maxMilestone} | Unlocked Tiers: ${bestiary.tiersUnlocked} / ${bestiary.totalTiers}`
54+
`${username}'s Bestiary Milestone: ${bestiary.milestone} / ${bestiary.maxMilestone} | Unlocked Tiers: ${bestiary.tiersUnlocked} / ${bestiary.totalTiers}`
5555
);
5656

5757
if (playerUsername === username) {
@@ -66,11 +66,11 @@ class EightBallCommand extends minecraftCommand {
6666

6767
await new Promise((resolve) => setTimeout(resolve, 1000));
6868

69-
this.send(`/gc Closest to level up: ${topFiveMobs.join(", ")}`);
69+
this.send(`Closest to level up: ${topFiveMobs.join(", ")}`);
7070
}
7171
} catch (error) {
7272
console.log(error);
73-
this.send(`/gc [ERROR] ${error}`);
73+
this.send(`[ERROR] ${error}`);
7474
}
7575
}
7676

@@ -91,4 +91,4 @@ class EightBallCommand extends minecraftCommand {
9191
}
9292
}
9393

94-
module.exports = EightBallCommand;
94+
module.exports = BestiaryCommand;

src/minecraft/commands/booCommand.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ class BooCommand extends minecraftCommand {
3232
}
3333

3434
if (this.isOnCooldown) {
35-
return this.send(`/gc ${this.name} Command is on cooldown`);
35+
return this.send(`${this.name} Command is on cooldown`);
3636
}
3737

3838
this.send(`/boo ${this.getArgs(message)[0]}`);
3939
await delay(690);
4040
this.send(`/msg ${this.getArgs(message)[0]} ${username} Booed You!`);
4141
await delay(690);
42-
this.send(`/gc Booed ${this.getArgs(message)[0]}!`);
42+
this.send(`Booed ${this.getArgs(message)[0]}!`);
4343
this.isOnCooldown = true;
4444
// CREDITS: @jaxieflaxie for finding this cooldown reset
4545
setTimeout(() => {
@@ -55,7 +55,7 @@ class BooCommand extends minecraftCommand {
5555
}, 30000);
5656
this.isOnCooldown = false;
5757
} catch (error) {
58-
this.send(`/gc [ERROR] ${error}`);
58+
this.send(`[ERROR] ${error}`);
5959
}
6060
}
6161
}

0 commit comments

Comments
 (0)