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

Make Kord builder no longer suspend #146

Open
BartArys opened this issue Dec 19, 2020 · 4 comments
Open

Make Kord builder no longer suspend #146

BartArys opened this issue Dec 19, 2020 · 4 comments

Comments

@BartArys
Copy link
Contributor

Kord's builder DSL suspends to figure out the recommended amount of shards from Discord's REST API.
When it was originally introduced, it was motivated as a way to automatically scale shards without input from the user.
The truth is however, that most bot authors won't be running Kord bots on 1000+ guilds. Most will run a select few dedicated guilds instead, and those running on more won't be using a single kord instance for all their bots anyway.

As such, we should transform the builder to no longer suspend by default and assume a default shard config (1 shard, index 0) that can modified by the user, and allow them to call the suspending function manually. This makes building Kord nicer for third APIs and has the added bonus of skipping an HTTP request, speeding up the startup.

@DRSchlaubi
Copy link
Member

I'll actually run Kord on a 4k guilds bot at some point so what about adding both ways

@BartArys
Copy link
Contributor Author

BartArys commented Dec 27, 2020

I'll actually run Kord on a 4k guilds bot at some point so what about adding both ways

This doesn't intend remove the behavior, it merely doesn't make it the default:

and allow them to call the suspending function manually.

conceptually that'd translate itself to something like this:

val kord = Kord(token) {
    shards = fetchRecommendedShards()
}

It should only be a bit of extra work for those who need it, and a decent optimization for those who don't.

@DRSchlaubi
Copy link
Member

The builder also calls DataCache.registerKordData() and DataCache.createView() the latter one is actually suspending for no reason but the first one is

@DRSchlaubi
Copy link
Member

Relates to #807, #779

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

No branches or pull requests

2 participants