Bot has Server Member Intent from Discord Dev Portal but DownloadUsersAsync still throws Missing required gateway intent GuildMembers
See original GitHub issueVersion: 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.
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:
- Created 2 years ago
- Comments:7
Top GitHub Comments
To add to this response:
DiscordSocketConfig
includes a field calledGatewayIntents
, which is a required configuration to set if you use any privileged intents. You can match theGatewayIntents
to what you have enabled in the portal. If you are not sure what all the intents imply, useGatewayIntents.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:
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.