Method CreateSharded
- Namespace
- DSharpPlus
- Assembly
- DSharpPlus.dll
CreateSharded(string, DiscordIntents, uint?, IServiceCollection?)
Creates a new sharding DiscordClientbuilder using the specified token.
public static DiscordClientBuilder CreateSharded(string token, DiscordIntents intents, uint? shardCount = null, IServiceCollection? serviceCollection = null)
Parameters
token
stringThe token to use for this application.
intents
DiscordIntentsThe intents to connect to the gateway with.
shardCount
uint?The amount of shards to start.
serviceCollection
IServiceCollectionThe service collection to base this builder on.
Returns
- DiscordClientBuilder
A new DiscordClientBuilder.
Remarks
DSharpPlus supports more advanced sharding over just specifying the amount of shards, which can be accessed
through the underlying service collection:
builder.ConfigureServices(services =>
{
services.Configure<ShardingOptions>(x => ...);
// The default orchestrator supports a shard count and a "stride" (offset from shard 0), which requires
// a total shard count. If you wish to customize sharding further, you can specify your own orchestrator:
services.AddSingleton<IShardOrchestrator, MyCustomShardOrchestrator>();
}</code></pre>