Table of Contents

Class DiscordClientBuilder

Namespace
DSharpPlus
Assembly
DSharpPlus.dll

Enables building a DiscordClient from complex configuration, registering extensions and fine-tuning behavioural aspects.

public sealed class DiscordClientBuilder
Inheritance
object
DiscordClientBuilder
Extension Methods

Methods

Build()

Builds a new client from the present builder.

ConfigureEventHandlers(Action<EventHandlingBuilder>)

Configures event handlers on the present client builder.

ConfigureExtraFeatures(Action<DiscordConfiguration>)

Tweaks assorted extra configuration knobs around the library.

ConfigureGatewayClient(Action<GatewayClientOptions>)

Configures the gateway client used by DSharpPlus.

ConfigureLogging(Action<ILoggingBuilder>)

Configures logging for this DiscordClientBuilder and disables the default DSharpPlus logger.

ConfigureRestClient(Action<RestClientOptions>)

Configures the rest client used by DSharpPlus.

ConfigureServices(Action<IServiceCollection>)

Configures services on this DiscordClientBuilder, enabling you to customize the library or your own services.

ConfigureSharding(Action<ShardingOptions>)

Configures the sharding attempted by DSharpPlus. Throws if the builder was not set up for sharding.

ConnectAsync()

Builds the client and connects to Discord. The client instance will be unobtainable in user code.

CreateDefault(string, DiscordIntents, IServiceCollection?)

Creates a new DiscordClientBuilder without sharding, using the specified token.

CreateSharded(string, DiscordIntents, uint?, IServiceCollection?)

Creates a new sharding DiscordClientbuilder using the specified token.

DisableDefaultLogging()

Disables the DSharpPlus default logger for this DiscordClientBuilder.

DisableGatewayCompression()

Disables gateway compression entirely.

SetLogLevel(LogLevel)

Sets the log level for the default logger, should it be used.

SetReconnectOnFatalGatewayErrors()

Instructs DSharpPlus to try reconnecting when encountering a fatal gateway error. By default, DSharpPlus will leave the decision on fatal gateway errors to the user.

UseZlibCompression()

Sets the gateway compression used to zlib. This is the default compression mode.

UseZstdCompression()

Sets the gateway compression used to zstd. This requires zstd natives to be available to the application.