I was coding a bot for Discord using Discord.net. I have an IGuild where I need to get a User by id, so I'm using:
var user = await guild.GetUserAsync(id, CacheMode.AllowDownload);
This should get the user if cached, and if not, download it. But the user is null every time.
I know the id is correct. Is there a proper way to do this?
The Server has > 1k members so downloading them through DownloadUsersAsync takes way too long.
Arriving late to the party.
Your problem is a direct consequence of the new Gateway Intents, put in place by Discord on their API.
Not to worry, this is an easy fix. Just go to https://discord.com/developers/applications, select your App, then got to the bot section. You're then looking for this. Just enable Server Members Intent.
If everything went to plan, this should transparently fix your issue without even needing to recompile. Short of that, feel free to ask again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With