Skip to content

Commit 7371273

Browse files
committed
Merge branch 'main' into officer
2 parents be0c957 + 33cfb3b commit 7371273

20 files changed

+323
-173
lines changed

API/constants/xp_tables.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ module.exports = {
1313
social: 25,
1414
dungeoneering: 50,
1515
hotm: 10,
16+
gardenXp: 15,
17+
wheat: 46,
18+
carrot: 46,
19+
potato: 46,
20+
melon: 46,
21+
pumpkin: 46,
22+
sugarCane: 46,
23+
cocoaBeans: 46,
24+
cactus: 46,
25+
mushroom: 46,
26+
netherWart: 46,
1627
},
1728
normal: [
1829
50, 125, 200, 300, 500, 750, 1000, 1500, 2000, 3500, 5000, 7500, 10000, 15000, 20000, 30000, 50000, 75000, 100000,
@@ -44,4 +55,65 @@ module.exports = {
4455
blaze: [10, 30, 250, 1500, 5000, 20000, 100000, 400000, 1000000],
4556
vampire: [20, 75, 240, 840, 2400],
4657
},
58+
gardenXp: [0, 70, 70, 140, 240, 600, 1500, 2000, 2500, 3000, 10000, 10000, 10000, 10000, 10000],
59+
wheat: [
60+
30, 50, 80, 170, 330, 670, 1330, 2500, 3500, 5000, 6500, 8000, 10000, 20000, 35000, 50000, 75000, 100000, 175000,
61+
250000, 350000, 500000, 750000, 1000000, 1300000, 1600000, 2000000, 2300000, 2600000, 3000000, 3000000, 3000000,
62+
3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000,
63+
3000000,
64+
],
65+
carrot: [
66+
100, 150, 250, 500, 1500, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 40000, 70000, 100000, 200000, 250000,
67+
250000, 500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000,
68+
10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000,
69+
10000000, 10000000, 10000000, 10000000, 10000000,
70+
],
71+
potato: [
72+
100, 150, 250, 500, 1500, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 40000, 70000, 100000, 200000, 250000,
73+
250000, 500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000,
74+
10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000,
75+
10000000, 10000000, 10000000, 10000000, 10000000,
76+
],
77+
melon: [
78+
150, 250, 400, 850, 1650, 3350, 6650, 12500, 17500, 25000, 32500, 40000, 50000, 100000, 175000, 250000, 375000,
79+
500000, 875000, 1250000, 1750000, 2500000, 3750000, 5000000, 6500000, 8000000, 10000000, 11500000, 13000000,
80+
15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000,
81+
15000000, 15000000, 15000000, 15000000, 15000000, 15000000,
82+
],
83+
pumpkin: [
84+
30, 50, 80, 170, 330, 670, 1330, 2500, 3500, 5000, 6500, 8000, 10000, 20000, 35000, 50000, 75000, 100000, 175000,
85+
250000, 350000, 500000, 750000, 1000000, 1300000, 1600000, 2000000, 2300000, 2600000, 3000000, 3000000, 3000000,
86+
3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000,
87+
3000000,
88+
],
89+
sugarCane: [
90+
60, 100, 160, 340, 660, 1340, 2660, 5000, 7000, 10000, 13000, 16000, 20000, 40000, 70000, 100000, 150000, 200000,
91+
350000, 500000, 700000, 1000000, 1500000, 2000000, 2600000, 3200000, 4000000, 4600000, 5200000, 6000000, 6000000,
92+
6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000,
93+
6000000, 6000000,
94+
],
95+
cocoaBeans: [
96+
90, 150, 250, 500, 1000, 2000, 4000, 7500, 10000, 15000, 20000, 25000, 30000, 50000, 100000, 150000, 200000, 300000,
97+
500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 9000000,
98+
9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000,
99+
9000000, 9000000,
100+
],
101+
cactus: [
102+
60, 100, 160, 340, 660, 1340, 2660, 5000, 7000, 10000, 13000, 16000, 20000, 40000, 70000, 100000, 150000, 200000,
103+
350000, 500000, 700000, 1000000, 1500000, 2000000, 2600000, 3200000, 4000000, 4600000, 5200000, 6000000, 6000000,
104+
6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000,
105+
6000000, 6000000,
106+
],
107+
mushroom: [
108+
30, 50, 80, 170, 330, 670, 1330, 2500, 3500, 5000, 6500, 8000, 10000, 20000, 35000, 50000, 75000, 100000, 175000,
109+
250000, 350000, 500000, 750000, 1000000, 1300000, 1600000, 2000000, 2300000, 2600000, 3000000, 3000000, 3000000,
110+
3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000,
111+
3000000,
112+
],
113+
netherWart: [
114+
90, 150, 250, 500, 1000, 2000, 4000, 7500, 10000, 15000, 20000, 25000, 30000, 50000, 100000, 150000, 200000, 300000,
115+
500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 9000000,
116+
9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000,
117+
9000000, 9000000,
118+
],
47119
};

API/functions/getGarden.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* eslint-disable no-throw-literal */
2+
const config = require("../../config.json");
3+
const axios = require("axios");
4+
5+
async function getGarden(profileID, uuid) {
6+
try {
7+
const { data } = await axios.get(
8+
`https://api.hypixel.net/v2/skyblock/garden?key=${config.minecraft.API.hypixelAPIkey}&profile=${profileID}`,
9+
);
10+
11+
if (data === undefined || data.success === false) {
12+
throw "Request to Hypixel API failed. Please try again!";
13+
}
14+
15+
return { garden: data.garden };
16+
} catch (e) {
17+
throw new Error(e);
18+
}
19+
}
20+
21+
module.exports = { getGarden };

API/functions/getLatestProfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* eslint-disable no-throw-literal */
22
const { getUUID } = require("../../src/contracts/API/mowojangAPI.js");
33
const { getMuseum } = require("./getMuseum.js");
4+
const { getGarden } = require("./getGarden.js");
45
const { isUuid } = require("../utils/uuid.js");
56
const config = require("../../config.json");
67
const axios = require("axios");
78

89
const cache = new Map();
910

10-
async function getLatestProfile(uuid, options = { museum: false }) {
11+
async function getLatestProfile(uuid, options = { museum: false, garden: false }) {
1112
if (!isUuid(uuid)) {
1213
uuid = await getUUID(uuid).catch((error) => {
1314
throw error;
@@ -59,6 +60,7 @@ async function getLatestProfile(uuid, options = { museum: false }) {
5960
playerRes: playerRes.player,
6061
uuid: uuid,
6162
...(options.museum ? await getMuseum(profileData.profile_id, uuid) : {}),
63+
...(options.garden ? await getGarden(profileData.profile_id) : {}),
6264
};
6365

6466
cache.set(uuid, output);

API/stats/garden.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const calcSkill = require("../constants/skills.js");
2+
3+
module.exports = (profile) => {
4+
return {
5+
level: calcSkill("gardenXp", profile?.garden_experience || 0),
6+
cropMilesstone: {
7+
wheat: calcSkill("wheat", profile?.resources_collected?.WHEAT || 0),
8+
carrot: calcSkill("carrot", profile?.resources_collected?.CARROT_ITEM || 0),
9+
sugarCane: calcSkill("sugarCane", profile?.resources_collected?.SUGAR_CANE || 0),
10+
potato: calcSkill("potato", profile?.resources_collected?.POTATO_ITEM || 0),
11+
netherWart: calcSkill("netherWart", profile?.resources_collected?.NETHER_STALK || 0),
12+
pumpkin: calcSkill("pumpkin", profile?.resources_collected?.PUMPKIN || 0),
13+
melon: calcSkill("melon", profile?.resources_collected?.MELON || 0),
14+
mushroom: calcSkill("mushroom", profile?.resources_collected?.MUSHROOM_COLLECTION || 0),
15+
cocoaBeans: calcSkill("cocoaBeans", profile?.resources_collected?.["INK_SACK:3"] || 0),
16+
cactus: calcSkill("cactus", profile?.resources_collected?.CACTUS || 0),
17+
},
18+
};
19+
};

data/linked.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Application.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
const MinecraftManager = require("./minecraft/MinecraftManager.js");
2+
const { existsSync, mkdirSync, writeFileSync } = require("fs");
23
const DiscordManager = require("./discord/DiscordManager.js");
34
const webManager = require("./web/WebsiteManager.js");
4-
// eslint-disable-next-line no-unused-vars
5-
const Configuration = require("./Configuration.js");
6-
// eslint-disable-next-line no-unused-vars
7-
const Updater = require("./Updater.js");
85

96
class Application {
7+
constructor() {
8+
require("./Configuration.js");
9+
require("./Updater.js");
10+
if (!existsSync("./data/")) mkdirSync("./data/", { recursive: true });
11+
if (!existsSync("./data/linked.json")) writeFileSync("./data/linked.json", JSON.stringify({}));
12+
}
13+
1014
async register() {
1115
this.discord = new DiscordManager(this);
1216
this.minecraft = new MinecraftManager(this);

src/discord/commands/blacklistCommand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ module.exports = {
2424
],
2525
},
2626
{
27-
name: "name",
27+
name: "username",
2828
description: "Minecraft Username",
2929
type: 3,
3030
required: true,
3131
},
3232
],
3333

3434
execute: async (interaction) => {
35-
const name = interaction.options.getString("name");
35+
const name = interaction.options.getString("username");
3636
const arg = interaction.options.getString("arg").toLowerCase();
3737

3838
if (arg == "add") {

src/discord/commands/demoteCommand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ module.exports = {
77
requiresBot: true,
88
options: [
99
{
10-
name: "name",
10+
name: "username",
1111
description: "Minecraft Username",
1212
type: 3,
1313
required: true,
1414
},
1515
],
1616

1717
execute: async (interaction) => {
18-
const name = interaction.options.getString("name");
18+
const name = interaction.options.getString("username");
1919
bot.chat(`/g demote ${name}`);
2020

2121
const embed = new SuccessEmbed(`Successfully demoted \`${name}\` by one guild rank.`);

src/discord/commands/forceVerifyCommand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
required: true,
1414
},
1515
{
16-
name: "name",
16+
name: "username",
1717
description: "Minecraft Username",
1818
type: 3,
1919
required: true,

src/discord/commands/helpCommand.js

Lines changed: 64 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const HypixelDiscordChatBridgeError = require("../../contracts/errorHandler.js")
22
const { EmbedBuilder } = require("discord.js");
33
const config = require("../../../config.json");
44
const fs = require("fs");
5+
const { getCommands } = require("./infoCommand.js");
56

67
module.exports = {
78
name: "help",
@@ -16,92 +17,77 @@ module.exports = {
1617
],
1718

1819
execute: async (interaction) => {
19-
const commandName = interaction.options.getString("command") || undefined;
20+
try {
21+
const commandName = interaction.options.getString("command") || undefined;
22+
const { discordCommands, minecraftCommands } = getCommands(interaction.client.commands);
2023

21-
if (commandName === undefined) {
22-
const discordCommands = interaction.client.commands
23-
.map(({ name, options }) => {
24-
const optionsString = options?.map(({ name, required }) => (required ? ` (${name})` : ` [${name}]`)).join("");
25-
return `- \`${name}${optionsString ? optionsString : ""}\`\n`;
26-
})
27-
.join("");
24+
if (commandName === undefined) {
25+
const helpMenu = new EmbedBuilder()
26+
.setColor(0x0099ff)
27+
.setTitle("Hypixel Discord Chat Bridge Commands")
28+
.setDescription("`()` = **required** argument, `[]` = **optional** argument\n`u` = Minecraft Username")
29+
.addFields(
30+
{
31+
name: "**Minecraft**: ",
32+
value: `${minecraftCommands}`,
33+
inline: true,
34+
},
35+
{
36+
name: "**Discord**: ",
37+
value: `${discordCommands}`,
38+
inline: true,
39+
},
40+
)
41+
.setFooter({
42+
text: "by @duckysolucky | /help [command] for more information",
43+
iconURL: "https://imgur.com/tgwQJTX.png",
44+
});
2845

29-
const minecraftCommands = fs
30-
.readdirSync("./src/minecraft/commands")
31-
.filter((file) => file.endsWith(".js"))
32-
.map((file) => {
33-
const command = new (require(`../../minecraft/commands/${file}`))();
34-
const optionsString = command.options
35-
?.map(({ name, required }) => (required ? ` (${name})` : ` [${name}]`))
36-
.join("");
46+
await interaction.followUp({ embeds: [helpMenu] });
47+
} else {
48+
const minecraftCommand = fs
49+
.readdirSync("./src/minecraft/commands")
50+
.filter((file) => file.endsWith(".js"))
51+
.map((file) => new (require(`../../minecraft/commands/${file}`))())
52+
.find((command) => command.name === commandName || command.aliases.includes(commandName));
3753

38-
return `- \`${command.name}${optionsString}\`\n`;
39-
})
40-
.join("");
54+
const type = minecraftCommand ? "minecraft" : "discord";
4155

42-
const helpMenu = new EmbedBuilder()
43-
.setColor(0x0099ff)
44-
.setTitle("Hypixel Discord Chat Bridge Commands")
45-
.setDescription("() = required argument, [] = optional argument")
46-
.addFields(
47-
{
48-
name: "**Minecraft**: ",
49-
value: `${minecraftCommands}`,
50-
inline: true,
51-
},
52-
{
53-
name: "**Discord**: ",
54-
value: `${discordCommands}`,
55-
inline: true,
56-
},
57-
)
58-
.setFooter({
59-
text: "by @duckysolucky | /help [command] for more information",
60-
iconURL: "https://imgur.com/tgwQJTX.png",
61-
});
56+
const command = interaction.client.commands.find((command) => command.name === commandName) ?? minecraftCommand;
57+
if (command === undefined) {
58+
throw new HypixelDiscordChatBridgeError(`Command ${commandName} not found.`);
59+
}
6260

63-
await interaction.followUp({ embeds: [helpMenu] });
64-
} else {
65-
const minecraftCommand = fs
66-
.readdirSync("./src/minecraft/commands")
67-
.filter((file) => file.endsWith(".js"))
68-
.map((file) => new (require(`../../minecraft/commands/${file}`))())
69-
.find((command) => command.name === commandName || command.aliases.includes(commandName));
61+
const description = `${
62+
command.aliases
63+
? `\nAliases: ${command.aliases
64+
.map((aliase) => {
65+
return `\`${config.minecraft.bot.prefix}${aliase}\``;
66+
})
67+
.join(", ")}\n\n`
68+
: ""
69+
}${command.description}\n\n${
70+
command.options
71+
?.map(({ name, required, description }) => {
72+
const optionString = required ? `(${name})` : `[${name}]`;
73+
return `\`${optionString}\`: ${description}\n`;
74+
})
75+
.join("") || ""
76+
}`;
7077

71-
const type = minecraftCommand ? "minecraft" : "discord";
78+
const embed = new EmbedBuilder()
79+
.setColor(0x0099ff)
80+
.setTitle(`**${type === "discord" ? "/" : config.minecraft.bot.prefix}${command.name}**`)
81+
.setDescription(description + "\n")
82+
.setFooter({
83+
text: "by @duckysolucky | () = required, [] = optional",
84+
iconURL: "https://imgur.com/tgwQJTX.png",
85+
});
7286

73-
const command = interaction.client.commands.find((command) => command.name === commandName) ?? minecraftCommand;
74-
if (command === undefined) {
75-
throw new HypixelDiscordChatBridgeError(`Command ${commandName} not found.`);
87+
await interaction.followUp({ embeds: [embed] });
7688
}
77-
78-
const description = `${
79-
command.aliases
80-
? `\nAliases: ${command.aliases
81-
.map((aliase) => {
82-
return `\`${config.minecraft.bot.prefix}${aliase}\``;
83-
})
84-
.join(", ")}\n\n`
85-
: ""
86-
}${command.description}\n\n${
87-
command.options
88-
?.map(({ name, required, description }) => {
89-
const optionString = required ? `(${name})` : `[${name}]`;
90-
return `\`${optionString}\`: ${description}\n`;
91-
})
92-
.join("") || ""
93-
}`;
94-
95-
const embed = new EmbedBuilder()
96-
.setColor(0x0099ff)
97-
.setTitle(`**${type === "discord" ? "/" : config.minecraft.bot.prefix}${command.name}**`)
98-
.setDescription(description + "\n")
99-
.setFooter({
100-
text: "by @duckysolucky | () = required, [] = optional",
101-
iconURL: "https://imgur.com/tgwQJTX.png",
102-
});
103-
104-
await interaction.followUp({ embeds: [embed] });
89+
} catch (error) {
90+
console.log(error);
10591
}
10692
},
10793
};

0 commit comments

Comments
 (0)