3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-14 21:31:50 +00:00

fix: catch and report errors when applying role button components

This commit is contained in:
Dragory 2022-04-23 20:17:32 +03:00
parent 22bd0ec422
commit 75bd7625a2
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -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,