On the event guildmemberupdate, I am trying to see if the event is in my server and if the role is a certain role. If all things are true, it will send a message. It does not send a message though
Here is the code
JavaScript
x
18
18
1
this.on('guildMemberUpdate', function (guild, oldMember, newMember) {
2
if(guild.id !== '#') {
3
return
4
} else {
5
const wc = new Discord.WebhookClient("#', 'lG-###-7RIXy3LIup80X");
6
if (oldMember.roles.cache.size !== newMember.roles.cache.size) {
7
8
if (!oldMember.roles.cache.has("851156630748921927") && newMember.roles.cache.has("851156630748921927")) {
9
wc.send(`yo !`);
10
}
11
12
}
13
14
}
15
16
17
})
18
It doesn’t send ‘test’
Advertisement
Answer
The guildMemberUpdate
event requires the server members intent. You can enable it in the Discord Developer Portal, and within your client instantiation
JavaScript
1
4
1
const { Intents } = require("discord.js")
2
const client = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS]})
3
//other intents may be added. Make sure it has server members intent (Intents.FLAGS.GUILD_MEMBERS)
4