aboutsummaryrefslogtreecommitdiff
path: root/build/hypixel.js
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-13 19:02:49 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-13 19:02:49 -0600
commit9b2856303374521b315759500cf594ec7f22d293 (patch)
treef1439e79f6b79ac2f32cfa08e58124bff553b502 /build/hypixel.js
parent728994f435e781eeffcba739698a1c21bba76a83 (diff)
downloadskyblock-api-9b2856303374521b315759500cf594ec7f22d293.tar.gz
skyblock-api-9b2856303374521b315759500cf594ec7f22d293.tar.bz2
skyblock-api-9b2856303374521b315759500cf594ec7f22d293.zip
fix some stats cutting off at the wrong place
Diffstat (limited to 'build/hypixel.js')
-rw-r--r--build/hypixel.js22
1 files changed, 6 insertions, 16 deletions
diff --git a/build/hypixel.js b/build/hypixel.js
index 847fbdb..9c67fe6 100644
--- a/build/hypixel.js
+++ b/build/hypixel.js
@@ -32,34 +32,24 @@ const profiles_1 = require("./cleaners/skyblock/profiles");
exports.saveInterval = 60 * 3 * 1000;
// the highest level a minion can be
exports.maxMinion = 11;
-/**
- * Send a request to api.hypixel.net using a random key, clean it up to be more useable, and return it
- */
-async function sendCleanApiRequest({ path, args }, included, cleaned = true) {
+async function sendCleanApiRequest({ path, args }, included, options) {
const key = await hypixelApi_1.chooseApiKey();
const rawResponse = await hypixelApi_1.sendApiRequest({ path, key, args });
if (rawResponse.throttled) {
// if it's throttled, wait a second and try again
console.log('throttled :/');
await new Promise(resolve => setTimeout(resolve, 1000));
- return await sendCleanApiRequest({ path, args }, included, cleaned);
- }
- if (cleaned) {
- // if it needs to clean the response, call cleanResponse
- return await cleanResponse({ path, data: rawResponse }, included = included);
- }
- else {
- // this is provided in case the caller wants to do the cleaning itself
- // used in skyblock/profile, as cleaning the entire profile would use too much cpu
- return rawResponse;
+ return await sendCleanApiRequest({ path, args }, included, options);
}
+ // clean the response
+ return await cleanResponse({ path, data: rawResponse }, options !== null && options !== void 0 ? options : {});
}
exports.sendCleanApiRequest = sendCleanApiRequest;
-async function cleanResponse({ path, data }, included) {
+async function cleanResponse({ path, data }, options) {
// Cleans up an api response
switch (path) {
case 'player': return await player_1.cleanPlayerResponse(data.player);
- case 'skyblock/profile': return await profile_1.cleanSkyblockProfileResponse(data.profile);
+ case 'skyblock/profile': return await profile_1.cleanSkyblockProfileResponse(data.profile, options);
case 'skyblock/profiles': return await profiles_1.cleanSkyblockProfilesResponse(data.profiles);
}
}