question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discord user is NULL

See original GitHub issue

Got some weird issues after the update to the latest lib version. I read user command from chat to proceed with authentication, get the author ID and then try to get SocketGuildUser using the SocketGuild.GetUser(ID) but it returns NULL. User is in the guild, transition from command to processing logic is less than a second. The problem is that the issue is floating, sometimes it works just fine.

  • I call await discordGuild.DownloadUsersAsync(); before the processing to make sure the cache is up to date.
  • I have one guild with strict ID specified
  • I have this one guild cached in a variable at startup (can be a problem here?)
  • Guild IsConnected and HasAllMembers properties are True. Restart do not solve it.

Please help me to get a clue on what is going on and how i can solve it.

PS: seems like users cache leaves old users after I purge them from discord and call DownloadUsersAsync, it shows 990 users against 737 in discord. After bot restart it shows correct 737 but the issue still remains. PS2: When I’ve added extended logging and restarted the bot one more time, it passed the check :E Will wait for another issue. Can’t reproduce with my alt reg.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:27 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
230Danielcommented, Nov 6, 2020

Just in case anybody hasn’t sussed this out, the GetUser(id) method only interacts with the client’s cache. If you’re having issues with the cache and need to get someone by ID, use GetUserAsync(id) which directly queries Discord’s REST API.

I found that on the nightly builds, neither AlwaysDownloadUsers = true nor SocketGuild.DownloadUsersAsync() work, despite having the GuildMembers and Guild intents enabled. They don’t throw an error, they just get stuck.

If I enable the presence intents, AlwaysDownloadUsers works again. I don’t see why presence data should be required to get the members of the server, so I’m putting this down to a bug in the library.

Assuming it is a bug with the library, it needs to be fixed as soon as possible because otherwise verified bots with the guild members intent but without the presence intent aren’t able to fill their user cache.

Edit: I have since discovered that DownloadUsersAsync() doesn’t work in the ready or guild available handlers, but using it in the connected / shardconnected handlers works great! I hope this helps.

3reactions
DaNeubicommented, Nov 13, 2020

Just in case anybody hasn’t sussed this out, the GetUser(id) method only interacts with the client’s cache. If you’re having issues with the cache and need to get someone by ID, use GetUserAsync(id) which directly queries Discord’s REST API.

I found that on the nightly builds, neither AlwaysDownloadUsers = true nor SocketGuild.DownloadUsersAsync() work, despite having the GuildMembers and Guild intents enabled. They don’t throw an error, they just get stuck.

If I enable the presence intents, AlwaysDownloadUsers works again. I don’t see why presence data should be required to get the members of the server, so I’m putting this down to a bug in the library.

Assuming it is a bug with the library, it needs to be fixed as soon as possible because otherwise verified bots with the guild members intent but without the presence intent aren’t able to fill their user cache.

Edit: I have since discovered that DownloadUsersAsync() doesn’t work in the ready or guild available handlers, but using it in the connected / shardconnected handlers works great! I hope this helps.

Indeed I can confirm, that you need both Intents. Only Server Member Intent does not work. This fixed it for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between deleted account and null account
Difference between deleted account and null account. Hey, all. I'm going through my discord data and I've found two kinds of discord IDs;....
Read more >
client.user is null in discord.js
1 Answer 1 ... It looks like you're creating a new Client for your 'work' module. As statted in discord.js docs, client.user is...
Read more >
User profile for null
Easy Solution to the Bad-Bot Problem ... I think this would go in Account and Server Mgmt, but I'm not sure, so feel...
Read more >
null Discord server
Request you all to join the null Discord server for easy and fast collaboration and better project management. --. Best Regards, Murtuja Bharmal...
Read more >
What Does "null" Mean On Discord? - Whoihavetobe
The meaning of “null” on Discord is that the app is trying to show you data but it is not able to fetch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found