Hello,
Please note this is not an issue that can be fixed by enabling the server members gateway intent, I have already enabled this.
Since what appears to be a few weeks ago, the guildMemberRemove event seems to not fire in some cases. I believe it has something to do with caching. If a user joins the guild and then leaves without restarting the Discord.js application, the event is fired correctly. The issue only seems to occur if a user joins the guild, the Discord.js application is restarted after a user has joined, and the user then leaves - this does not trigger the event.
Reproduction steps:
client.on("guildMemberRemove", (guildmember) => {
console.log("Member left: " + guildmember.id);
}
Further details:
Relevant client options:
other: none
[ ] I have also tested the issue on latest master, commit hash:
This is because the GuildMember is uncached - you will need the GUILD_MEMBER partial in order to listen for events for uncached GuildMembers.
https://discordjs.guide/popular-topics/partials.html?v=12
https://discord.js.org/#/docs/main/stable/topics/partials
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.
Thanks for the quick reply @monbrey Having read the documentation on Partials, this is potentially an issue for me then. My bot is in two separate guilds and it is crucial that I know which guild the member has been removed from.
If the GuildMember is partial, I won't be able to reliably access guildmember.guild.id from what I understand. Furthermore, because the GuildMember has been removed from the guild, there is no opportunity for me to fetch() the GuildMember.
How should I reliably obtain the following data from a partial GuildMember that has been removed from the guild, or at least find out which guild the member has been removed from?
Please take questions to the Discord server.
For anyone that finds this, quick summary of the Discord conversation following on from this:
space 🌹 replied to Albo1125Today at 22:44
A partial guild member object includes both guild and user.
Albo1125 replied to space 🌹Today at 22:46
That's a lifesaver. Is there anything else we can assume that a partial guildmember reliably includes? Given that on the Partials docs page it states specifically that Partial data is only ever guaranteed to contain an ID
space 🌹Today at 22:47
I think that's it for guild members.
MonbreyToday at 22:47
Generally speaking you can check what Discord actually emits for the event, and go from there
https://discord.com/developers/docs/topics/gateway#guild-member-remove-guild-member-remove-event-fields
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
The fact that this does include a guild_id means you'll know which guild
Common issues people run into for example is a partial Message object in messageDelete does not include its content
TL;DR Partial GuildMembers include both the guild and the user.