error handling on reaction roles
This commit is contained in:
parent
ddcec60be6
commit
474a35a736
@ -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.');
|
||||
}
|
||||
}
|
||||
|
@ -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.');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user