Table of Contents

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 string

The token to use for this application.

intents DiscordIntents

The intents to connect to the gateway with.

shardCount uint?

The amount of shards to start.

serviceCollection IServiceCollection

The 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>