SHARE
TWEET

Untitled

a guest Sep 17th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('messageReactionAdd', async (reaction, user) => {
  2.     if(reaction.message.id != '623729013197766686') return;
  3.     if (reaction.message.partial) await reaction.message.fetch();
  4.  
  5.     var roleName = reaction.emoji.name;
  6.     var role = reaction.message.guild.roles.find(role => role.name.toLowerCase() === roleName.toLowerCase());
  7.     var member = reaction.message.guild.members.find(member => member.id === user.id);
  8.    
  9.     member.addRole(role.id).then(member => {
  10.         console.log("Adeded " + member.user.username + " to the " + role.name + " role.");
  11.     }).catch(err => console.error);
  12.  
  13.   });
  14.  
  15.   client.on('messageReactionRemove', async (reaction, user) => {
  16.       if(reaction.message.id != '623729013197766686') return;
  17.    
  18.       var roleName = reaction.emoji.name;
  19.       var role = reaction.message.guild.roles.find(role => role.name.toLowerCase() === roleName.toLowerCase());
  20.       var member = reaction.message.guild.members.find(member => member.id === user.id);
  21.    
  22.     if (member.roles.has(role.id))
  23.     {
  24.         member.removeRole(role.id).then(member => {
  25.             console.log("Removed" + member.user.username + " from the " + role.name + " role.");
  26.         }).catch(err => console.error);
  27.     }
  28.   });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top