From f3d3371ba7c8227f4d14720821f51f14923bcef4 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 28 Dec 2021 18:54:27 -0600 Subject: ignore invalid keys --- src/hypixelApi.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') 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] = { -- cgit