From 75bd7625a2feec51d220c1c10e7527faf2646590 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:17:32 +0300 Subject: [PATCH] fix: catch and report errors when applying role button components --- .../plugins/RoleButtons/functions/applyRoleButtons.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/plugins/RoleButtons/functions/applyRoleButtons.ts b/backend/src/plugins/RoleButtons/functions/applyRoleButtons.ts index d79f9624..b3fc76f4 100644 --- a/backend/src/plugins/RoleButtons/functions/applyRoleButtons.ts +++ b/backend/src/plugins/RoleButtons/functions/applyRoleButtons.ts @@ -88,7 +88,7 @@ export async function applyRoleButtons( candidateMessage = await channel.send(configItem.message.content as string | MessageOptions); } catch (err) { pluginData.getPlugin(LogsPlugin).logBotAlert({ - body: `Error while posting message for role_buttons/${configItem.name}`, + body: `Error while posting message for role_buttons/${configItem.name}: ${String(err)}`, }); return null; } @@ -99,14 +99,19 @@ export async function applyRoleButtons( if (message.author.id !== pluginData.client.user?.id) { pluginData.getPlugin(LogsPlugin).logBotAlert({ - body: `Error applying role buttons for role_buttons/${configItem.name}: target message must be posted by the bot`, + body: `Error applying role buttons for role_buttons/${configItem.name}: target message must be posted by Zeppelin`, }); return null; } // Apply role buttons const components = createButtonComponents(configItem); - await message.edit({ components }); + await message.edit({ components }).catch((err) => { + pluginData.getPlugin(LogsPlugin).logBotAlert({ + body: `Error applying role buttons for role_buttons/${configItem.name}: ${String(err)}`, + }); + return null; + }); return { channel_id: message.channelId,