DiscordMember lacks of user properties when the cache is empty on Guild Member Removed event
See original GitHub issueSummary
The DiscordMember
entity doesn’t use the DiscordUser
’s properties, instead it searches this in the user cache.
Details
I found that the DiscordMember
entity doesn’t have the username, discriminator, avatar, basically all the general fields from the DiscordUser
entity when this is not in the cache.
I was searching the cause of this and I found that DiscordMember
searches the user in the user cache then it uses its properties.
I found this problem in the Guild Member Removed event when I started my bot with the cache empty. I believe Discord sends the full data of the user that left the server.
Steps to reproduce
- Start the bot with the cache empty (i.e. have only the member intent enabled or not)
- Try to access member’s username in the guild member removed event
- You will get a
KeyNotFoundException
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
None of my discord.js guildmember events are emitting ...
GUILD_PRESENCES. member and user caches are empty (or very close to it) on startup; Guild.memberCount returns count as of ready · GUILD_MEMBERS.
Read more >The guildMemberRemove event is not thrown when there ...
When a member enters the guild, the GUILD_MEMBER_ADD event occurs, caches the member and passes the event to the client.
Read more >Error when trying to read `message.guild.roles.cache`
I have no clue why the cache property is undefined in some cases and is defined in others. How would I find a...
Read more >Interactions API Reference - discord.py
Represents a Discord interaction. An interaction happens when a user does an action that needs to be notified. Current examples are slash commands...
Read more >Adding role gives an error: Cannot read property 'guild' of null
Hello, I'm trying to run this piece of code for my new bot. This is supposed to be a "muting" command, but it's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have only the member intent enabled. I found this in my bot dev and also in the logs of my public bot. I have the logs for it. I restarted my bot 2 days ago and this is one of the logs while trying to get the username of a member that left a guild and it wasn’t in the cache because the bot just started. The bot was supposed to send a leaving message. Maybe in your case the member was updated and added in the member cache, I don’t know.
Okay sorry for the long wait, I tested this and was able to reproduce. I will get this issue fixed soon.