Discord.Net
Discord.Net copied to clipboard
Allow specifying list of user ids in SocketGuild.DownloadUsersAsync
Discord supports specifying a list of user IDs in their Request Guild Members event, but Discord.NET currently does not expose this functionality.
I'm trying to use Discord.NET in a large server (>600k members) and my bot is interested in only a few (100-10,000) of those. Using DownloadUsersAsync to get all users takes very long and also shoots up RAM usage to >2GB
This PR is not really ready to merge (the changes work fine for my use case though), I'm mainly looking to get some feedback on what is needed to get this feature into Discord.NET.
I like this idea. @Misha-133 can you stress test this PR and see what you can find for bugs/bottlenecks?
await SocketGuild.DownloadUsersAsync(Array.Empty<ulong>());
~~Supplying an empty collection of users to download results in a deadlock~~
UPD: awaiting the method in a event handler causes a deadlock on the gateway thread
@quinchs Should DownloadUsersAsync methods block the thread until users are actually downloaded?
This causes deadlock if the method is executed in a event handler
DownloadUsersAsync method that we had before also has this issue. Shouldn't this be at least documented? Or maybe blocking should be tied to a bool parameter
_________ Everything seems to work fine otherwise
Once thing that's currently missing from this PR is this:
Requesting user_ids will continue to be limited to returning 100 members
so this must be chunked when requesting more than 100 members at once