aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/hypixelApi.js6
-rw-r--r--src/hypixelApi.ts6
2 files changed, 8 insertions, 4 deletions
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'))
diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts
index 9a0a6da..1de583b 100644
--- a/src/hypixelApi.ts
+++ b/src/hypixelApi.ts
@@ -173,8 +173,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 })
}