From 07d92497a362e9a15f6319c9b73b1280d6f39c87 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 28 Dec 2021 19:44:22 -0600 Subject: don't remove multiple times --- build/hypixelApi.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'build') diff --git a/build/hypixelApi.js b/build/hypixelApi.js index 35c3119..ae647b7 100644 --- a/build/hypixelApi.js +++ b/build/hypixelApi.js @@ -75,8 +75,10 @@ export let sendApiRequest = async function 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`); + if (apiKeys.includes(key)) { + apiKeys.splice(apiKeys.indexOf(key), 1); + console.log(`${key} is invalid, removing it from the list of keys`); + } return await sendApiRequest({ path, key: chooseApiKey(), args }); } if (fetchResponse.headers.get('ratelimit-limit')) -- cgit