From 86dd9f16693b545960f6480949590225ccb4d321 Mon Sep 17 00:00:00 2001 From: pilar6195 Date: Mon, 29 Jul 2024 20:11:00 -0500 Subject: [PATCH] fix: crude check for disabled anilist api --- package.json | 2 +- src/utils/Helpers.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c74ffb2..0680fdf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anilist-extras", - "version": "2.7.4", + "version": "2.7.5", "description": "Adds a few additional features to AniList.", "scripts": { "build": "bun run build.ts", diff --git a/src/utils/Helpers.ts b/src/utils/Helpers.ts index f3047c9..2d9aa13 100644 --- a/src/utils/Helpers.ts +++ b/src/utils/Helpers.ts @@ -304,6 +304,15 @@ export const anilistApi = async ( data: JSON.stringify({ query, variables }), }); + if (response.status === 403) { + const errorMessage = response.json?.errors?.[0]?.message; + if (errorMessage?.includes('disabled')) { + console.error(errorMessage); + // eslint-disable-next-line @typescript-eslint/no-throw-literal + throw response; + } + } + // If the request failed and the user has an api token, check if the token is invalid. if (apiToken && useApiToken && response.status === 400) { const invalidToken = response.json.errors.some((error: any) => error.message === 'Invalid token');