1
votes

Right now in discord.js, you can get all the users who have the role like this:

const guild = client.guilds.get('GUILD_ID')
Role = guild.roles.find(r => r.name === 'Big Yeeter').members.map(m=>m.user.tag);

But that gives all the users who have the role, not the users who have it for their highest role. For example, if their ranks would look like this:

HUGE yeeter
Big Yeeter
Small Yeeter

...they would still be logged.

But I just want to get the users who have it as their HIGHEST role, so only users like this:

Big Yeeter
Small Yeeter

Hopefully that makes sense. So how could I do something like that?

1
Take a look at the highestRole propertyT. Dirks

1 Answers

0
votes
    var role = message.guild.roles.find(r => r.name === 'Big Yeeter')
    var users = message.guild.members.map(m => m.id)
    users.forEach(x => {
      let thisMember = message.guild.members.get(x)
      if(thisMember.highestRole == role){
         console.log( thisMember.user)
      }

You just need to get every member of the guild and then verify if the role is the highest