guildMemberUpdate doesn't fire for users that joined when the bot was offline
Hello, I'm trying to make a bot that will give a role to an user that has accepted the server rules by checking for the pending property, what I found peculiar is that if the user joined when the bot is offline, when the bot comes back online it refuses to give that user a role even when that user accept the rules. And I also found out that calling
await client.guilds.cache.get(guildID).members.fetch()
on ready
event resolves that issue. Any heads up? Here is my code and a video demonstrating the issue. I have already enabled Guilds
and GuildMembers
intents, and this issue doesn't occur when the user joins when the bot is up.
Or more specifically, it doesn't even fire guildMemberUpdate
, as to why the console.log()
didn't fire. I don't want to call a fetch for guild members because my bot's prod guild has over 4k members.19 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.Extra Information:
Node Version:
16.17.0
Discord.js version: 14.4.0
What is partials?So I have to enable some partials for it to register offline users when coming back online?
Isn't this the guildMemberAdd event??
It is in
guildMemberUpdate
.I know, I'm talking about the member passing membership screening
with some logging
oldMember
is partial, I have to call .fetch()
?I think it emits a guildMemberAdd
Not a guildMemberUpdate
New member should be a full member
You can't fetch the old member
The
guildMemberAdd
event didn't fire when the user accepts the rules, I had a console.log()
in itYeah, my bad them
Is this viable to put in prod?
What you want to do?
Checking if the member is pending and add role if changes the state?
Yes
If it's working
Thats fine
Try this:
(oldMember.pending !== newMember.pending) || (!newMember.pending && !newMember.roles.cache.has(roleId))
let me try it out
Should work for all tree cases if I'm not dumb
It works
Thanks you guys for the support
❤️
Makes sense, my bad on that