-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
156 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-disable no-throw-literal */ | ||
const config = require("../../config.json"); | ||
const axios = require("axios"); | ||
|
||
async function getGarden(profileID, uuid) { | ||
try { | ||
const { data } = await axios.get( | ||
`https://api.hypixel.net/v2/skyblock/garden?key=${config.minecraft.API.hypixelAPIkey}&profile=${profileID}`, | ||
); | ||
|
||
if (data === undefined || data.success === false) { | ||
throw "Request to Hypixel API failed. Please try again!"; | ||
} | ||
|
||
return { garden: data.garden }; | ||
} catch (e) { | ||
throw new Error(e); | ||
} | ||
} | ||
|
||
module.exports = { getGarden }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const calcSkill = require("../constants/skills.js"); | ||
|
||
module.exports = (profile) => { | ||
return { | ||
level: calcSkill("gardenXp", profile?.garden_experience || 0), | ||
cropMilesstone: { | ||
wheat: calcSkill("wheat", profile?.resources_collected?.WHEAT || 0), | ||
carrot: calcSkill("carrot", profile?.resources_collected?.CARROT_ITEM || 0), | ||
sugarCane: calcSkill("sugarCane", profile?.resources_collected?.SUGAR_CANE || 0), | ||
potato: calcSkill("potato", profile?.resources_collected?.POTATO_ITEM || 0), | ||
netherWart: calcSkill("netherWart", profile?.resources_collected?.NETHER_STALK || 0), | ||
pumpkin: calcSkill("pumpkin", profile?.resources_collected?.PUMPKIN || 0), | ||
melon: calcSkill("melon", profile?.resources_collected?.MELON || 0), | ||
mushroom: calcSkill("mushroom", profile?.resources_collected?.MUSHROOM_COLLECTION || 0), | ||
cocoaBeans: calcSkill("cocoaBeans", profile?.resources_collected?.["INK_SACK:3"] || 0), | ||
cactus: calcSkill("cactus", profile?.resources_collected?.CACTUS || 0), | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { getLatestProfile } = require("../../../API/functions/getLatestProfile.js"); | ||
const { formatUsername } = require("../../contracts/helperFunctions.js"); | ||
const minecraftCommand = require("../../contracts/minecraftCommand.js"); | ||
const getGarden = require("../../../API/stats/garden.js"); | ||
|
||
class GardenCommand extends minecraftCommand { | ||
constructor(minecraft) { | ||
super(minecraft); | ||
|
||
this.name = "garden"; | ||
this.aliases = []; | ||
this.description = "Skyblock Garden Stats of specified user."; | ||
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 data = await getLatestProfile(username, { garden: true }); | ||
username = formatUsername(username, data.profileData?.game_mode); | ||
const garden = getGarden(data.garden); | ||
|
||
this.send( | ||
`/gc ${username}'s garden ${garden.level.level} | Crop Milestones: Wheat: ${garden.cropMilesstone.wheat.level} | Carrot: ${garden.cropMilesstone.carrot.level} | Cane: ${garden.cropMilesstone.sugarCane.level} | Potato: ${garden.cropMilesstone.potato.level} | Wart: ${garden.cropMilesstone.netherWart.level} | Pumpkin: ${garden.cropMilesstone.pumpkin.level} | Melon: ${garden.cropMilesstone.melon.level} | Mushroom: ${garden.cropMilesstone.mushroom.level} | Cocoa: ${garden.cropMilesstone.cocoaBeans.level} | Cactus: ${garden.cropMilesstone.cactus.level}`, | ||
); | ||
} catch (error) { | ||
this.send(`/gc [ERROR] ${error}`); | ||
} | ||
} | ||
} | ||
|
||
module.exports = GardenCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters