From ed89751f4084a02dd4201f06596559390dafef39 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Thu, 16 May 2024 18:42:48 +0100 Subject: [PATCH] fix: don't crash --- bot/src/slashCommands/commands/sync.ts | 4 ++++ bot/src/utils/apiRequests.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bot/src/slashCommands/commands/sync.ts b/bot/src/slashCommands/commands/sync.ts index 94ebdb402..b0a5cbaf4 100644 --- a/bot/src/slashCommands/commands/sync.ts +++ b/bot/src/slashCommands/commands/sync.ts @@ -51,6 +51,10 @@ const command: SlashCommand = { interaction ); + if (typeof importDoc === "string") { + return importDoc; + } + return CreateImportEmbed(importDoc); }, }; diff --git a/bot/src/utils/apiRequests.ts b/bot/src/utils/apiRequests.ts index 9effdd713..b98a3841b 100644 --- a/bot/src/utils/apiRequests.ts +++ b/bot/src/utils/apiRequests.ts @@ -112,8 +112,12 @@ export async function PerformScoreImport( ); if (!initRes.success) { - logger.error(`Failed to perform score import on ${url}.`, { body }); - throw new Error(`Failed to perform import on ${url}.`); + if (initRes.statusCode >= 500) { + logger.error(`Failed to perform score import on ${url}.`, { body }); + throw new Error(`Failed to perform import on ${url}.`); + } else { + return initRes.description; + } } // this server does not defer imports to a scorequeue