diff options
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] = { |