From a7d71e07629915f44a577c290d4213dfa618bab4 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Tue, 2 Nov 2021 21:00:23 +0200 Subject: [PATCH] fix: log all errors when attempting to create a webhook and gracefully return --- .../functions/getOrCreateWebhookForChannel.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts b/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts index ec05f473..9d2fb029 100644 --- a/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts +++ b/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts @@ -35,12 +35,13 @@ export async function getOrCreateWebhookForChannel( }); return [webhook.id, webhook.token!]; } catch (err) { + console.warn(`Error when trying to create webhook for ${pluginData.guild.id}/${channel.id}: ${err.message}`); + if (isDiscordAPIError(err) && err.code === 50013) { pluginData.state.missingPermissions = true; - console.warn(`Error ${err.code} when trying to create webhook for ${pluginData.guild.id}`); - return null; } - throw err; + + return null; } }