debug: catch & trace interaction reply errors

This commit is contained in:
Dragory 2022-06-01 18:58:54 +03:00
parent 016330366e
commit 6df67da3cb
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 27 additions and 15 deletions
backend/src/plugins/RoleButtons/events

View file

@ -23,10 +23,12 @@ export const onButtonInteraction = typedGuildEventListener<RoleButtonsPluginType
const buttons = config.buttons[name];
const option: TRoleButtonOption | undefined = buttons?.options[optionIndex];
if (!buttons || !option) {
args.interaction.reply({
ephemeral: true,
content: "Invalid option selected",
});
args.interaction
.reply({
ephemeral: true,
content: "Invalid option selected",
})
.catch((err) => console.trace(err.message));
return;
}
@ -39,10 +41,12 @@ export const onButtonInteraction = typedGuildEventListener<RoleButtonsPluginType
if (member.roles.cache.has(option.role_id)) {
rolesToRemove.push(option.role_id);
args.interaction.reply({
ephemeral: true,
content: `The role **${roleName}** will be removed shortly!`,
});
args.interaction
.reply({
ephemeral: true,
content: `The role **${roleName}** will be removed shortly!`,
})
.catch((err) => console.trace(err.message));
} else {
rolesToAdd.push(option.role_id);
@ -54,10 +58,12 @@ export const onButtonInteraction = typedGuildEventListener<RoleButtonsPluginType
}
}
args.interaction.reply({
ephemeral: true,
content: `You will receive the **${roleName}** role shortly!`,
});
args.interaction
.reply({
ephemeral: true,
content: `You will receive the **${roleName}** role shortly!`,
})
.catch((err) => console.trace(err.message));
}
for (const roleId of rolesToAdd) {