Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Incomplete Ready, DownloadUsersAsync, and optimize AlwaysDownloadUsers #1548

Merged
merged 5 commits into from
Jun 18, 2020

Conversation

SubZero0
Copy link
Member

@SubZero0 SubZero0 commented May 24, 2020

Summary

There were three issues related to how these were being done:

  • It was possible to Ready to fire before downloading all guild data because some large guilds can take more than two seconds to be received so it will assume it's over. I was able to always reproduce this locally with Discord API (the guild) with a small bot, would take a lot more time.
  • AlwaysDownloadUsers would fire one gateway request to download members per guild, making it easily reach the gateway limit of 120 requests per minute, when this request, without gateway intents, can receive an array of guild_ids (tested up to 200, but limited to 100 since it isn't documented).
  • The wrong variable was being used to calculate count in DownloadUsersAsync, returning a negative number.

Changes

  • Add property MaxWaitBetweenGuildAvailablesBeforeReady to DiscordSocketConfig that will let the user decide how long they want to wait, zero being an option (firing READY without waiting GUILD_AVAILABLEs).
  • Change default wait time to 10,000ms instead of 2,000ms (large guilds can take more time than 2 seconds) to avoid firing READY before all guild data is downloaded.
  • Adjust the maximum batch size for a Request Guild Members gateway request (tested up to 200 and it still worked fine).
  • Fixed how count is calculated in DownloadUsersAsync

SubZero0 added 3 commits May 23, 2020 23:58
Ready could fire before downloading all guild data and downloading guild users one guild per time without gateway intents is a waste of a gateway request that can support up to 1000.
@foxbot foxbot merged commit dc8c959 into discord-net:dev Jun 18, 2020
@SubZero0 SubZero0 deleted the fix-ready-and-alwaysdownloadusers branch June 18, 2020 20:59
anonymousheadless pushed a commit to anonymousheadless/Discord.Net that referenced this pull request Mar 29, 2021
…dUsers (discord-net#1548)

* Fix Ready and AlwaysDownloadUsers

Ready could fire before downloading all guild data and downloading guild users one guild per time without gateway intents is a waste of a gateway request that can support up to 1000.

* Reduce batchSize and fix count

* Fix typo

* Split xml docs line

Co-authored-by: Christopher Felegy <cfelegy@riseup.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants