Reputation: 113
The bot only sends a private message to me if I have the SPECIFIED ROLE.
It does not write to other users with the SPECIFIED ROLE.
What is the problem?
client.on("message", (msg) => {
if (msg.guild && msg.content.startsWith("!private")) {
if (msg.author.id === "55430860840......") {
const text = msg.content.slice("!private".length);
const staffID = "747217324.......";
msg.guild.members.cache.forEach((member) => {
if(member.roles.cache.has(staffID)) {member.send(text)} })
}
}
});
Upvotes: 0
Views: 819
Reputation: 89
you can do:
message.guild.members.cache.forEach(member => {
if (member._roles.includes('<Role ID>')) {
member.send(<message>)
}
})
Upvotes: 1