Table of Contents

Class DiscordClient

Namespace
DSharpPlus
Assembly
DSharpPlus.dll

A Discord API wrapper.

public sealed class DiscordClient : BaseDiscordClient
Inheritance
DiscordClient
Inherited Members
Extension Methods

Constructors

DiscordClient(DiscordConfiguration)

Initializes a new instance of DiscordClient.

Properties

GatewayInfo

Gets the gateway session information for this client.

GatewayUri

Gets the gateway URL.

GatewayVersion

Gets the gateway protocol version.

Guilds

Gets a dictionary of guilds that this client is in. The dictionary's key is the guild ID. Note that the guild objects in this dictionary will not be filled in if the specific guilds aren't available (the GuildAvailable or GuildDownloadCompleted events haven't been fired yet)

Intents

Gets the intents configured for this client.

IsConnected

Gets whether this client is connected to the gateway.

Ping

Gets the WS latency for this client.

Presences

Gets the collection of presences held by this client.

PrivateChannels

Gets a dictionary of DM channels that have been cached by this client. The dictionary's key is the channel ID.

ShardCount

Gets the total number of shards the bot is connected to.

ShardId

Gets the currently connected shard ID.

Methods

AddExtension(BaseExtension)

Registers an extension with this client.

BulkOverwriteGlobalApplicationCommandsAsync(IEnumerable<DiscordApplicationCommand>)

Overwrites the existing global application commands. New commands are automatically created and missing commands are automatically deleted.

BulkOverwriteGuildApplicationCommandsAsync(ulong, IEnumerable<DiscordApplicationCommand>)

Overwrites the existing application commands in a guild. New commands are automatically created and missing commands are automatically deleted.

ConnectAsync(DiscordActivity, DiscordUserStatus?, DateTimeOffset?)

Connects to the gateway

CreateGlobalApplicationCommandAsync(DiscordApplicationCommand)

Creates or overwrites a global application command.

CreateGuildApplicationCommandAsync(ulong, DiscordApplicationCommand)

Creates or overwrites a guild application command.

CreateGuildAsync(string, string?, Optional<Stream>, DiscordVerificationLevel?, DiscordDefaultMessageNotifications?, DiscordSystemChannelFlags?)

Creates a guild. This requires the bot to be in less than 10 guilds total.

CreateGuildFromTemplateAsync(string, string, Optional<Stream>)

Creates a guild from a template. This requires the bot to be in less than 10 guilds total.

DeleteGlobalApplicationCommandAsync(ulong)

Deletes a global application command.

DeleteGuildApplicationCommandAsync(ulong, ulong)

Deletes a application command in a guild.

DisconnectAsync()

Disconnects from the gateway

Dispose()

Disposes your DiscordClient.

EditGlobalApplicationCommandAsync(ulong, Action<ApplicationCommandEditModel>)

Edits a global application command.

EditGuildApplicationCommandAsync(ulong, ulong, Action<ApplicationCommandEditModel>)

Edits a application command in a guild.

GetChannelAsync(ulong)

Gets a channel

GetConnectionsAsync()

Gets a list of connections

GetExtension<T>()

Retrieves a previously-registered extension from this client.

GetGlobalApplicationCommandAsync(string)

Gets a global application command by its name.

GetGlobalApplicationCommandAsync(ulong)

Gets a global application command by its id.

GetGlobalApplicationCommandsAsync()

Gets all the global application commands for this application.

GetGuildApplicationCommandAsync(ulong, ulong)

Gets a application command in a guild by its ID.

GetGuildApplicationCommandsAsync(ulong)

Gets all the application commands for a guild.

GetGuildAsync(ulong, bool?)

Gets a guild.

Setting withCounts to true will make a REST request.

GetGuildPreviewAsync(ulong)

Gets a guild preview

GetGuildsAfterAsync(ulong, int, bool?, CancellationToken)

Returns a list of guilds after a certain guild. This will execute one API request per 200 guilds.

The amount of guilds to fetch.The ID of the guild after which we fetch the guilds.Whether to include approximate member and presence counts in the returned guilds.Cancels the enumeration before doing the next api request
GetGuildsAsync(int, bool?, CancellationToken)

Returns a list of guilds the bot is in. This will execute one API request per 200 guilds.

The amount of guilds to fetch.Whether to include approximate member and presence counts in the returned guilds.Cancels the enumeration before doing the next api request
GetGuildsBeforeAsync(ulong, int, bool?, CancellationToken)

Returns a list of guilds before a certain guild. This will execute one API request per 200 guilds.

The amount of guilds to fetch.The ID of the guild before which we fetch the guildsWhether to include approximate member and presence counts in the returned guilds.Cancels the enumeration before doing the next api request
GetInviteByCodeAsync(string, bool?, bool?)

Gets an invite.

GetStickerAsync(ulong)

Gets a sticker.

GetStickerPacksAsync()

Gets a collection of sticker packs that may be used by nitro users.

GetTemplateAsync(string)

Gets a guild template by the code.

GetUserAsync(ulong, bool)

Gets a user

GetWebhookAsync(ulong)

Gets a webhook

GetWebhookWithTokenAsync(ulong, string)

Gets a webhook

ReconnectAsync(bool)
SendMessageAsync(DiscordChannel, DiscordEmbed)

Sends a message

SendMessageAsync(DiscordChannel, DiscordMessageBuilder)

Sends a message

SendMessageAsync(DiscordChannel, Action<DiscordMessageBuilder>)

Sends a message

SendMessageAsync(DiscordChannel, string)

Sends a message

SendMessageAsync(DiscordChannel, string, DiscordEmbed)

Sends a message

SendPayloadAsync(GatewayOpCode, object?)

Sends a raw payload to the gateway. This method is not recommended for use unless you know what you're doing.

SendPayloadAsync<T>(GatewayOpCode, T)

Sends a raw payload to the gateway. This method is not recommended for use unless you know what you're doing.

UpdateCurrentUserAsync(string, Optional<Stream>)

Edits current user.

UpdateStatusAsync(DiscordActivity, DiscordUserStatus?, DateTimeOffset?)

Updates current user's activity and status.

Events

ApplicationCommandPermissionsUpdated
AutoModerationRuleCreated

Fired when a new auto-moderation rule is created.

AutoModerationRuleDeleted

Fired when an auto-moderation rule is deleted.

AutoModerationRuleExecuted

Fired when an auto-moderation is executed.

AutoModerationRuleUpdated

Fired when an auto-moderation rule is updated.

ChannelCreated

Fired when a new channel is created. For this Event you need the Guilds intent specified in Intents

ChannelDeleted

Fired when a channel is deleted For this Event you need the Guilds intent specified in Intents

ChannelPinsUpdated

Fired whenever a channel's pinned message list is updated. For this Event you need the Guilds intent specified in Intents

ChannelUpdated

Fired when a channel is updated. For this Event you need the Guilds intent specified in Intents

ClientErrored

Fired whenever an error occurs within an event handler.

ComponentInteractionCreated

Fired when a component is invoked.

ContextMenuInteractionCreated

Fired when a user uses a context menu.

DmChannelDeleted

Fired when a dm channel is deleted For this Event you need the DirectMessages intent specified in Intents

GuildAuditLogCreated

Fired when a audit log entry is created.

GuildAvailable

Fired when a guild is becoming available. For this Event you need the Guilds intent specified in Intents

GuildBanAdded

Fired when a guild ban gets added For this Event you need the GuildModeration intent specified in Intents

GuildBanRemoved

Fired when a guild ban gets removed For this Event you need the GuildModeration intent specified in Intents

GuildCreated

Fired when the user joins a new guild. For this Event you need the Guilds intent specified in Intents

GuildDeleted

Fired when the user leaves or is removed from a guild. For this Event you need the Guilds intent specified in Intents

GuildDownloadCompleted

Fired when all guilds finish streaming from Discord.

GuildEmojisUpdated

Fired when a guilds emojis get updated For this Event you need the GuildEmojisAndStickers intent specified in Intents

GuildIntegrationsUpdated

Fired when a guild integration is updated.

GuildMemberAdded

Fired when a new user joins a guild. For this Event you need the GuildMembers intent specified in Intents

GuildMemberRemoved

Fired when a user is removed from a guild (leave/kick/ban). For this Event you need the GuildMembers intent specified in Intents

GuildMemberUpdated

Fired when a guild member is updated. For this Event you need the GuildMembers intent specified in Intents

GuildMembersChunked

Fired in response to Gateway Request Guild Members.

GuildRoleCreated

Fired when a guild role is created. For this Event you need the Guilds intent specified in Intents

GuildRoleDeleted

Fired when a guild role is updated. For this Event you need the Guilds intent specified in Intents

GuildRoleUpdated

Fired when a guild role is updated. For this Event you need the Guilds intent specified in Intents

GuildStickersUpdated
GuildUnavailable

Fired when a guild becomes unavailable.

GuildUpdated

Fired when a guild is updated. For this Event you need the Guilds intent specified in Intents

Heartbeated

Fired on received heartbeat ACK.

IntegrationCreated

Fired when an integration is created.

IntegrationDeleted

Fired when an integration is deleted.

IntegrationUpdated

Fired when an integration is updated.

InteractionCreated

Fired when an interaction is invoked.

InviteCreated

Fired when an invite is created. For this Event you need the GuildInvites intent specified in Intents

InviteDeleted

Fired when an invite is deleted. For this Event you need the GuildInvites intent specified in Intents

MessageCreated

Fired when a message is created. For this Event you need the GuildMessages intent specified in Intents

MessageDeleted

Fired when a message is deleted. For this Event you need the GuildMessages intent specified in Intents

MessageReactionAdded

Fired when a reaction gets added to a message. For this Event you need the GuildMessageReactions intent specified in Intents

MessageReactionRemoved

Fired when a reaction gets removed from a message. For this Event you need the GuildMessageReactions intent specified in Intents

MessageReactionRemovedEmoji

Fired when all reactions of a specific reaction are removed from a message. For this Event you need the GuildMessageReactions intent specified in Intents

MessageReactionsCleared

Fired when all reactions get removed from a message. For this Event you need the GuildMessageReactions intent specified in Intents

MessageUpdated

Fired when a message is updated. For this Event you need the GuildMessages intent specified in Intents

MessagesBulkDeleted

Fired when multiple messages are deleted at once. For this Event you need the GuildMessages intent specified in Intents

ModalSubmitted

Fired when a modal is submitted. If a modal is closed, this event is not fired.

PresenceUpdated

Fired when a presence has been updated. For this Event you need the GuildPresences intent specified in Intents

ScheduledGuildEventCompleted
ScheduledGuildEventCreated
ScheduledGuildEventDeleted
ScheduledGuildEventUpdated
ScheduledGuildEventUserAdded
ScheduledGuildEventUserRemoved
SessionCreated

Fired when this client has successfully completed its handshake with the websocket gateway.

SessionResumed

Fired whenever a session is resumed.

SocketClosed

Fired whenever WebSocket connection is terminated.

SocketErrored

Fired whenever a WebSocket error occurs within the client.

SocketOpened

Fired whenever WebSocket connection is established.

StageInstanceCreated

Fired when a stage instance is created.

StageInstanceDeleted

Fired when a stage instance is deleted.

StageInstanceUpdated

Fired when a stage instance is updated.

ThreadCreated

Fired when a thread is created. For this Event you need the Guilds intent specified in Intents

ThreadDeleted

Fired when a thread is deleted. For this Event you need the Guilds intent specified in Intents

ThreadListSynced

Fired when the current member gains access to a channel(s) that has threads. For this Event you need the Guilds intent specified in Intents

ThreadMemberUpdated

Fired when the thread member for the current user is updated. For this Event you need the Guilds intent specified in Intents

ThreadMembersUpdated

Fired when the thread members are updated. For this Event you need the GuildMembers or Guilds intent specified in Intents

ThreadUpdated

Fired when a thread is updated. For this Event you need the Guilds intent specified in Intents

TypingStarted

Fired when a user starts typing in a channel.

UnknownEvent

Fired when an unknown event gets received.

UserSettingsUpdated

Fired when the current user updates their settings. For this Event you need the GuildPresences intent specified in Intents

UserUpdated

Fired when properties about the current user change.

VoiceServerUpdated

Fired when a guild's voice server is updated. For this Event you need the GuildVoiceStates intent specified in Intents

VoiceStateUpdated

Fired when someone joins/leaves/moves voice channels. For this Event you need the GuildVoiceStates intent specified in Intents

WebhooksUpdated

Fired whenever webhooks update.

Zombied

Fired on heartbeat attempt cancellation due to too many failed heartbeats.