diff options
author | mat-1 <github@matdoes.dev> | 2021-06-02 00:41:52 +0000 |
---|---|---|
committer | mat-1 <github@matdoes.dev> | 2021-06-02 00:41:52 +0000 |
commit | 4d7552c19f85de7137457fd443b05dc9eb7d1e6c (patch) | |
tree | f250e824fe99b61a6ac5b73bb0000f42535f72db /build/hypixelApi.js | |
parent | b14a077a9bc35384d7561fd1b39bdad389cc4a53 (diff) | |
download | skyblock-api-4d7552c19f85de7137457fd443b05dc9eb7d1e6c.tar.gz skyblock-api-4d7552c19f85de7137457fd443b05dc9eb7d1e6c.tar.bz2 skyblock-api-4d7552c19f85de7137457fd443b05dc9eb7d1e6c.zip |
Compiled TS into JS
Diffstat (limited to 'build/hypixelApi.js')
-rw-r--r-- | build/hypixelApi.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/build/hypixelApi.js b/build/hypixelApi.js index 9f54ef2..59a798c 100644 --- a/build/hypixelApi.js +++ b/build/hypixelApi.js @@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; var _a, _b, _c; Object.defineProperty(exports, "__esModule", { value: true }); -exports.sendApiRequest = exports.chooseApiKey = void 0; +exports.sendApiRequest = exports.getKeyUsage = exports.chooseApiKey = void 0; /** * Fetch the raw Hypixel API */ @@ -27,7 +27,7 @@ function chooseApiKey() { // find the api key with the lowest amount of uses let bestKeyUsage = null; let bestKey = null; - for (var key of util_1.shuffle(apiKeys)) { + for (let key of util_1.shuffle(apiKeys)) { const keyUsage = apiKeyUsage[key]; // if the key has never been used before, use it if (!keyUsage) @@ -44,6 +44,19 @@ function chooseApiKey() { return bestKey; } exports.chooseApiKey = chooseApiKey; +function getKeyUsage() { + let keyLimit = 0; + let keyUsage = 0; + for (let key of Object.values(apiKeyUsage)) { + keyLimit += key.limit; + keyUsage += key.limit - key.remaining; + } + return { + limit: keyLimit, + usage: keyUsage + }; +} +exports.getKeyUsage = getKeyUsage; /** Send an HTTP request to the Hypixel API */ async function sendApiRequest({ path, key, args }) { // Send a raw http request to api.hypixel.net, and return the parsed json |