From 5c3fbec2ba97c495f2e70695453e7fb88a489d2c Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 28 Dec 2021 19:04:47 -0600 Subject: build --- build/hypixelApi.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'build/hypixelApi.js') 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] = { -- cgit