Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement