From ad800e335ca1e608f6db0b7f2673db3b8fe1fc0b Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 18 Aug 2021 23:02:56 +0300 Subject: [PATCH] Improve companion channel error handling --- .../functions/handleCompanionPermissions.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/src/plugins/CompanionChannels/functions/handleCompanionPermissions.ts b/backend/src/plugins/CompanionChannels/functions/handleCompanionPermissions.ts index 6ee14cf6..d6e3e764 100644 --- a/backend/src/plugins/CompanionChannels/functions/handleCompanionPermissions.ts +++ b/backend/src/plugins/CompanionChannels/functions/handleCompanionPermissions.ts @@ -68,13 +68,24 @@ export async function handleCompanionPermissions( }); } } catch (e) { - if (isDiscordAPIError(e) && e.code === 50001) { + if (isDiscordAPIError(e)) { const logs = pluginData.getPlugin(LogsPlugin); - logs.logBotAlert({ - body: `Missing permissions to handle companion channels. Pausing companion channels for 5 minutes or until the bot is reloaded on this server.`, - }); - pluginData.state.errorCooldownManager.setCooldown(ERROR_COOLDOWN_KEY, ERROR_COOLDOWN); - return; + + if (e.code === 50001) { + logs.logBotAlert({ + body: `One of the companion channels can't be accessed. Pausing companion channels for 5 minutes or until the bot is reloaded on this server.`, + }); + pluginData.state.errorCooldownManager.setCooldown(ERROR_COOLDOWN_KEY, ERROR_COOLDOWN); + return; + } + + if (e.code === 50013) { + logs.logBotAlert({ + body: `Missing permissions to handle companion channels. Pausing companion channels for 5 minutes or until the bot is reloaded on this server.`, + }); + pluginData.state.errorCooldownManager.setCooldown(ERROR_COOLDOWN_KEY, ERROR_COOLDOWN); + return; + } } throw e;