[Solved] guildMemberUpdate event only firing after second nickname change

I'm trying to detect when someone changes their nickname.
const Discord = require('discord.js')
const Client = new Discord.Client({ allowedMentions: [], intents: [Discord.GatewayIntentBits.GuildMembers] })
Client.login("MYTOKEN")
Client.once('ready', () => {
console.log("Online")
})
Client.on('guildMemberUpdate', (oldMember, newMember) => {
console.log("Test")
})
const Discord = require('discord.js')
const Client = new Discord.Client({ allowedMentions: [], intents: [Discord.GatewayIntentBits.GuildMembers] })
Client.login("MYTOKEN")
Client.once('ready', () => {
console.log("Online")
})
Client.on('guildMemberUpdate', (oldMember, newMember) => {
console.log("Test")
})
Output:
"Online"
*Nickname change*
*Nickname change2*
"Test"
*Nickname change3*
"Test"
"Online"
*Nickname change*
*Nickname change2*
"Test"
*Nickname change3*
"Test"
13 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Maxi130
Maxi130OP2y ago
└── [email protected] v16.17.1
Parogo_72
Parogo_722y ago
you are missing Guilds intent and you will need GuildMember partial
d.js docs
d.js docs2y ago
guide Popular Topics: Partial Structures read more
Maxi130
Maxi130OP2y ago
So it also fires for the first change?
Parogo_72
Parogo_722y ago
yes
Maxi130
Maxi130OP2y ago
The changes are all done after the bot printed online.
Parogo_72
Parogo_722y ago
if the member wasnt cached, oldMember would be a partial
Maxi130
Maxi130OP2y ago
Ah.
Parogo_72
Parogo_722y ago
and if you dont have partials enabled, the event wont fire
Maxi130
Maxi130OP2y ago
I thought the event sends it.
Parogo_72
Parogo_722y ago
no, the event (discord) only sends the new data
Maxi130
Maxi130OP2y ago
Ah, thank you. Solved.

Did you find this page helpful?