aboutsummaryrefslogtreecommitdiff
path: root/build/hypixelApi.js
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-28 19:04:47 -0600
committermat <github@matdoes.dev>2021-12-28 19:04:47 -0600
commit5c3fbec2ba97c495f2e70695453e7fb88a489d2c (patch)
tree9b8c76e7b12051c083018ef415a1fb027f1ed440 /build/hypixelApi.js
parentf3d3371ba7c8227f4d14720821f51f14923bcef4 (diff)
downloadskyblock-api-5c3fbec2ba97c495f2e70695453e7fb88a489d2c.tar.gz
skyblock-api-5c3fbec2ba97c495f2e70695453e7fb88a489d2c.tar.bz2
skyblock-api-5c3fbec2ba97c495f2e70695453e7fb88a489d2c.zip
build
Diffstat (limited to 'build/hypixelApi.js')
-rw-r--r--build/hypixelApi.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/build/hypixelApi.js b/build/hypixelApi.js
index da1be16..2377eca 100644
--- a/build/hypixelApi.js
+++ b/build/hypixelApi.js
@@ -72,6 +72,12 @@ export let sendApiRequest = async function sendApiRequest({ path, key, args }) {
await new Promise((resolve) => setTimeout(resolve, 30000));
return await sendApiRequest({ path, key, args });
}
+ // if the cause is "Invalid API key", remove the key from the list of keys and try again
+ if (fetchJsonParsed.cause === 'Invalid API key') {
+ apiKeys.splice(apiKeys.indexOf(key), 1);
+ console.log(`${key} is invalid, removing it from the list of keys`);
+ return await sendApiRequest({ path, key: null, args });
+ }
if (fetchResponse.headers.get('ratelimit-limit'))
// remember how many uses it has
apiKeyUsage[key] = {