Reputation: 33
With the following code, the guildMemberUpdate event does not call for any user modification at all except for the bot user. What could have caused this change, and how do I troubleshoot this?
VSC with latest npm install of discord.js. Enabled the gateway intents on Discord, too.
client.on('guildMemberUpdate', (oldMember, newMember) => {
// Fire if user has a role
if (newMember.roles.cache.some(r => r.name === "TEST_ROLE")) {
try {
// stuff
} catch(err) {
// stuff
}
}
})
Upvotes: 3
Views: 5261
Reputation: 151
It looks like you did not enable Guild Members Intent! To enable, go to: https://discord.com/developers/applications
Now click on your bot application.
Click on "Bot" on the left panel.
Scroll down until you see "Privileged Gateway Intents".
Below that are two toggles.
Toggle "Guild Members Intent" and save.
Hoped this helped you!
Further reading: https://discord.com/developers/docs/topics/gateway
Upvotes: 3