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.

Bot has Server Member Intent from Discord Dev Portal but DownloadUsersAsync still throws Missing required gateway intent GuildMembers

See original GitHub issue

Version: Discord.NET v3 Discord.WebSocket.DiscordSocketClient.DownloadUsersAsync starts to throw

System.InvalidOperationException: Missing required gateway intent GuildMembers in order to execute this operation.
at Discord.WebSocket.DiscordSocketClient.EnsureGatewayIntent(GatewayIntents intents)
at Discord.WebSocket.DiscordSocketClient.DownloadUsersAsync(IEnumerable`1 guilds)

Expected: Should work since it was working in v2.4 and my app has Server Member Intent.

After I upgraded to v3. When running v2.4 this was fine. Discord Developer Portal shows that my app has Server Member Intent, which is the one I applied for long time ago and was working fine until I upgraded to v3.

image

Update1: It has been awhile since I last call this method in my code in production. Just reverted back to v2.4 and will verify that after deployment is done.

Update2: Confirmed that Discord.WebSocket.DiscordSocketClient.DownloadUsersAsync works fine after I revert back to v2.4. The reason I tried to call DownloadUserAsync is because I noticed my bot’s user cache isn’t getting populated after the build with v3 booted up so I tried to manually “force” it. I think there is another issue with user cache not getting populated in v3 when it should be.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
csmircommented, Dec 22, 2021

To add to this response:

DiscordSocketConfig includes a field called GatewayIntents, which is a required configuration to set if you use any privileged intents. You can match the GatewayIntents to what you have enabled in the portal. If you are not sure what all the intents imply, use GatewayIntents.All as the value for this option, as it adds all unprivileged and privileged intents to your socketclient.

Edit: The reason why it does not work now is because Discord API v9 requires intents to be set by the client, previous API versions did not.

Example:


var config = new DiscordSocketConfig() 
{
    ... // any other options
    GatewayIntents = GatewayIntents.All
}
_client = new DiscordSocketClient(config);
0reactions
xenoverse-uscommented, Dec 22, 2021
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildMembers | ..

As mentioned here, you can stack several intents. Specifying only GuildMembers gets rid of several other intents that are required in your case. Adding the AllUnprivileged* intent would solve the issue. This adds a group of intents that are required for using several ‘regular’ events like listening for messages, from the GuildMessages, DirectMessages intents.

*unprivileged, thus not required to enable in the developer portal.

Thanks for sharing this. I was about to try to OR those two flags together myself. I can confirm that it indeed fixes the issue for me.

Hopefully, Discord API version change could also be documented here https://discordnet.dev/guides/v2_v3_guide/v2_to_v3_guide.html so that we are aware of potential need to configure GatewayIntents.

Anyways, thanks for the help, please consider this issue closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DownloadUsersAsync() "doesn't work" · Issue #1679
You only need the server members intent to be able to download and receive users in gateway events (except GUILD_CREATE that needs the...
Read more >
Guild Member Intent Missing, even though Guildmember ...
Guild Member Intent Missing, even though Guildmember Intent is activated Discord.NET. I am developing a Bot in which you can apply for Teams ......
Read more >
Gateway Intents | discord.js Guide
If your bot is not verified and in less than 100 guilds, you can enable privileged gateway intents in the Discord Developer Portal...
Read more >
Can someone give me some insight into a bot issue I have ...
I get this error in powershell : "WARNING:discord.ext.commands.bot:Privileged message content intent is missing, commands may not work as ...
Read more >
A Primer to Gateway Intents - discord.py - Read the Docs
A privileged intent is one that requires you to go to the developer portal and manually enable it. To enable privileged intents do...
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