diff --git a/events/reactionAdd.js b/events/reactionAdd.js index 6207c40..536b61d 100644 --- a/events/reactionAdd.js +++ b/events/reactionAdd.js @@ -37,7 +37,13 @@ export async function execute(reaction, user) { const role = await guild.roles.fetch(rep.role); if (role === null) return; - // Add role to user - await guild.members.addRole({ role, user }); - console.info(`[INFO] Added role with id '${role.id}' to user '${user.username}'.`); + try { + // Add role to user + await guild.members.addRole({ role, user }); + console.info(`[INFO] Added role with id '${role.id}' to user '${user.username}'.`); + } catch (error) { + // Missing permissions + console.error(error); + await user.send('Unable to assign role. Please contact server staff.'); + } } diff --git a/events/reactionRemove.js b/events/reactionRemove.js index 2888bf9..0cc52f1 100644 --- a/events/reactionRemove.js +++ b/events/reactionRemove.js @@ -33,7 +33,13 @@ export async function execute(reaction, user) { const role = await guild.roles.fetch(rep.role); if (role === null) return; - // Add role to user - await guild.members.removeRole({ role, user }); - console.info(`[INFO] Removed role with id '${role.id}' from user '${user.username}'.`); + try { + // Remove role from user + await guild.members.removeRole({ role, user }); + console.info(`[INFO] Removed role with id '${role.id}' from user '${user.username}'.`); + } catch (error) { + // Missing permissions + console.error(error); + await user.send('Unable to retract role. Please contact server staff.'); + } }