diff options
author | mat <github@matdoes.dev> | 2021-12-28 18:54:27 -0600 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-12-28 18:54:27 -0600 |
commit | f3d3371ba7c8227f4d14720821f51f14923bcef4 (patch) | |
tree | 359fb41c1e7508a4b677abaa1aebf5f142d9acf5 /src | |
parent | bca09d564c7e2511f378e33b205b5f37e0fa8984 (diff) | |
download | skyblock-api-f3d3371ba7c8227f4d14720821f51f14923bcef4.tar.gz skyblock-api-f3d3371ba7c8227f4d14720821f51f14923bcef4.tar.bz2 skyblock-api-f3d3371ba7c8227f4d14720821f51f14923bcef4.zip |
ignore invalid keys
Diffstat (limited to 'src')
-rw-r--r-- | src/hypixelApi.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts index dd5e08c..6939ea2 100644 --- a/src/hypixelApi.ts +++ b/src/hypixelApi.ts @@ -170,6 +170,13 @@ export let sendApiRequest = async function sendApiRequest({ path, key, args }): 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] = { |