'message.guild.roles.cache.get(roleID).members returns some members and sometimes none at all
So I used message.guild.roles.cache.get(roleID).members to get the members that have a role but I only get some of them or it only returns a member if I have the role here's my code
let roleId = "812004859439218758"
const valorantRosterMsg = new Discord.MessageEmbed()
.setTitle ("Valorant Roster")
.setDescription (msg.guild.roles.cache.get(roleId).members.map(m=>m.user).join('\n'))
msg.channel.send(valorantRosterMsg)
Solution 1:[1]
The most likely issue is that you haven't enabled the server members intent, which is required to get a full list of members. You can do so here on your bot page:
Solution 2:[2]
put in your code
msg.guild.members.fetch()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dinty |
| Solution 2 | anoq |

