daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bot.on("message", async message => {
  2.     if(message.content.startsWith("!rolelist")){
  3.     let roleName = message.content.split(" ").slice(1).join(" ");
  4.  
  5.     //Filtering the guild members only keeping those with the role
  6.     //Then mapping the filtered array to their usernames
  7.     let membersWithRole = message.guild.members.filter(member => {
  8.         message.guild.roles.find(r => r.name === 'yourrolename');
  9.     }).map(member => {
  10.         return member.user.username;
  11.     })
  12.  
  13.     let embed = new Discord.RichEmbed({
  14.         "title": `Users with the ${roleName} role`,
  15.         "description": membersWithRole.join("\n"),
  16.         "color": 0xFFFF
  17.     });
  18.  
  19.     return message.channel.send({embed});
  20. }
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