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

Proposal: Expose Shards property from GetBotGatewayResponse object in some way. #961

Closed
Seeker1437 opened this issue Feb 23, 2018 · 5 comments · Fixed by #962
Closed

Proposal: Expose Shards property from GetBotGatewayResponse object in some way. #961

Seeker1437 opened this issue Feb 23, 2018 · 5 comments · Fixed by #962

Comments

@Seeker1437
Copy link
Contributor

Seeker1437 commented Feb 23, 2018

Because of the way I have been developing my bot, I wanted it from the very beginning to be able to retrieve the correct shard count recommended by discord. During the login process the data is retrieved but it is not exposed in the public API.

I would like to propose exposing this property or it's data in the public API in someone wanted to use it when starting their shards manually without using the DiscordShardedClient object.

If this does not fit the "meta" is there an alternative method I can use to acquire this information myself?

@shikhir-arora
Copy link

When your bot is under 100,000 guilds, you have some flexibility with shard counts. 2,500 guilds/shard is the enforced limit by Discord, but this is higher than you'll see almost anyone do - realistically 1,000-1,800 guilds per shard is what I've seen. You can calculate this by just taking the total guilds your bot has or theoretically will, finding a good guild/shard number and dividing.

If you mean which guild will go to what shard, as messages (DMs) are sent to shard 0 only, the formula:

(guild_id >> 22) % num_shards == shard_id

will give you the shard_id -- after you exceed 100,000 guilds, however, Discord will contact you and assign a number of shards based on your bot. This is only for those very large bots.

@foxbot
Copy link
Member

foxbot commented Feb 23, 2018

@shikhir-arora no, Discord provides an endpoint to calculate the recommended number of shards for you - he's just asking us to expose that endpoint in the library.

@Seeker1437
Copy link
Contributor Author

I guess I did it wrong is just linking my PR here haha, #962

@AntiTcb
Copy link
Collaborator

AntiTcb commented Feb 23, 2018

Gotta leave a "fixes/resolves #962" in either the commit message or PR description, not the title for it to do that automagically. https://help.github.com/articles/closing-issues-using-keywords/

@Seeker1437
Copy link
Contributor Author

Updated :D

foxbot pushed a commit that referenced this issue Mar 15, 2018
* Move REST requests to appropiate class

* Add call to ClientHelper and expose to public API

* Expose shard count request in public api

* Expose method from interface

* Update sharded client to utilize the new method

* Method is already implemented in a base class

* Refactor name to fit pattern for methods returning a `Task`

* Adds missing ConfigureAwait

* Corrects unnecessary whitespace

* Removes unneeded whitespace
FiniteReality pushed a commit to FiniteReality/Discord.Net that referenced this issue May 5, 2018
* Move REST requests to appropiate class

* Add call to ClientHelper and expose to public API

* Expose shard count request in public api

* Expose method from interface

* Update sharded client to utilize the new method

* Method is already implemented in a base class

* Refactor name to fit pattern for methods returning a `Task`

* Adds missing ConfigureAwait

* Corrects unnecessary whitespace

* Removes unneeded whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants