Class DiscordShardedClient
A Discord client that shards automatically.
Inheritance
Namespace: DSharpPlus
Assembly: cs.temp.dll.dll
Syntax
public sealed class DiscordShardedClient
Constructors
DiscordShardedClient(DiscordConfiguration)
Initializes new auto-sharding Discord client.
Declaration
public DiscordShardedClient(DiscordConfiguration config)
Parameters
Type | Name | Description |
---|---|---|
DiscordConfiguration | config | Configuration to use. |
Properties
CurrentApplication
Gets the current application.
Declaration
public DiscordApplication CurrentApplication { get; }
Property Value
Type | Description |
---|---|
DiscordApplication |
CurrentUser
Gets the current user.
Declaration
public DiscordUser CurrentUser { get; }
Property Value
Type | Description |
---|---|
DiscordUser |
GatewayInfo
Gets the gateway info for the client's session.
Declaration
public GatewayInfo GatewayInfo { get; }
Property Value
Type | Description |
---|---|
GatewayInfo |
Logger
Gets the logger for this client.
Declaration
public ILogger<BaseDiscordClient> Logger { get; }
Property Value
Type | Description |
---|---|
ILogger<BaseDiscordClient> |
ShardClients
Gets all client shards.
Declaration
public IReadOnlyDictionary<int, DiscordClient> ShardClients { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<System.Int32, DiscordClient> |
VoiceRegions
Gets the list of available voice regions. Note that this property will not contain VIP voice regions.
Declaration
public IReadOnlyDictionary<string, DiscordVoiceRegion> VoiceRegions { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<System.String, DiscordVoiceRegion> |
Methods
Finalize()
Declaration
protected void Finalize()
GetShard(DiscordGuild)
Gets a shard from a guild.
This method uses the GetShardId(UInt64, Int32) method and will not iterate through the shard guild caches.
Declaration
public DiscordClient GetShard(DiscordGuild guild)
Parameters
Type | Name | Description |
---|---|---|
DiscordGuild | guild | The guild for the shard. |
Returns
Type | Description |
---|---|
DiscordClient | The found DiscordClient shard. |
GetShard(UInt64)
Gets a shard from a guild id.
This method uses the GetShardId(UInt64, Int32) method and will not iterate through the shard guild caches.
Declaration
public DiscordClient GetShard(ulong guildId)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | guildId | The guild id for the shard. |
Returns
Type | Description |
---|---|
DiscordClient | The found DiscordClient shard. |
StartAsync()
Initializes and connects all shards.
Declaration
public Task StartAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
StopAsync()
Disconnects and disposes of all shards.
Declaration
public Task StopAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
UpdateStatusAsync(DiscordActivity, Nullable<UserStatus>, Nullable<DateTimeOffset>)
Updates playing statuses on all shards.
Declaration
public Task UpdateStatusAsync(DiscordActivity activity = null, UserStatus? userStatus = default(UserStatus? ), DateTimeOffset? idleSince = default(DateTimeOffset? ))
Parameters
Type | Name | Description |
---|---|---|
DiscordActivity | activity | Activity to set. |
System.Nullable<UserStatus> | userStatus | Status of the user. |
System.Nullable<DateTimeOffset> | idleSince | Since when is the client performing the specified activity. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Asynchronous operation. |
Events
ChannelCreated
Declaration
public event AsyncEventHandler<DiscordClient, ChannelCreateEventArgs> ChannelCreated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, ChannelCreateEventArgs> |
ChannelDeleted
Declaration
public event AsyncEventHandler<DiscordClient, ChannelDeleteEventArgs> ChannelDeleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, ChannelDeleteEventArgs> |
ChannelPinsUpdated
Fired whenever a channel's pinned message list is updated. For this Event you need the Guilds intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, ChannelPinsUpdateEventArgs> ChannelPinsUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, ChannelPinsUpdateEventArgs> |
ChannelUpdated
Declaration
public event AsyncEventHandler<DiscordClient, ChannelUpdateEventArgs> ChannelUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, ChannelUpdateEventArgs> |
ClientErrored
Fired whenever an error occurs within an event handler.
Declaration
public event AsyncEventHandler<DiscordClient, ClientErrorEventArgs> ClientErrored
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, ClientErrorEventArgs> |
DmChannelDeleted
Fired when a dm channel is deleted For this Event you need the DirectMessages intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, DmChannelDeleteEventArgs> DmChannelDeleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, DmChannelDeleteEventArgs> |
GuildAvailable
Fired when a guild is becoming available.
Declaration
public event AsyncEventHandler<DiscordClient, GuildCreateEventArgs> GuildAvailable
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildCreateEventArgs> |
GuildBanAdded
Declaration
public event AsyncEventHandler<DiscordClient, GuildBanAddEventArgs> GuildBanAdded
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildBanAddEventArgs> |
GuildBanRemoved
Fired when a guild ban gets removed For this Event you need the GuildBans intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, GuildBanRemoveEventArgs> GuildBanRemoved
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildBanRemoveEventArgs> |
GuildCreated
Fired when the user joins a new guild. For this Event you need the Guilds intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, GuildCreateEventArgs> GuildCreated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildCreateEventArgs> |
Equivalent names
GuildJoined, JoinedGuild
GuildDeleted
Fired when the user leaves or is removed from a guild. For this Event you need the Guilds intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, GuildDeleteEventArgs> GuildDeleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildDeleteEventArgs> |
GuildDownloadCompleted
Fired when all guilds finish streaming from Discord.
Declaration
public event AsyncEventHandler<DiscordClient, GuildDownloadCompletedEventArgs> GuildDownloadCompleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildDownloadCompletedEventArgs> |
GuildEmojisUpdated
Fired when a guilds emojis get updated For this Event you need the GuildEmojis intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, GuildEmojisUpdateEventArgs> GuildEmojisUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildEmojisUpdateEventArgs> |
GuildIntegrationsUpdated
Fired when a guild integration is updated.
Declaration
public event AsyncEventHandler<DiscordClient, GuildIntegrationsUpdateEventArgs> GuildIntegrationsUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildIntegrationsUpdateEventArgs> |
GuildMemberAdded
Fired when a new user joins a guild. For this Event you need the GuildMembers intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, GuildMemberAddEventArgs> GuildMemberAdded
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildMemberAddEventArgs> |
GuildMemberRemoved
Fired when a user is removed from a guild (leave/kick/ban). For this Event you need the GuildMembers intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, GuildMemberRemoveEventArgs> GuildMemberRemoved
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildMemberRemoveEventArgs> |
GuildMembersChunked
Fired in response to Gateway Request Guild Members.
Declaration
public event AsyncEventHandler<DiscordClient, GuildMembersChunkEventArgs> GuildMembersChunked
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildMembersChunkEventArgs> |
GuildMemberUpdated
Fired when a guild member is updated. For this Event you need the GuildMembers intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, GuildMemberUpdateEventArgs> GuildMemberUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildMemberUpdateEventArgs> |
GuildRoleCreated
Declaration
public event AsyncEventHandler<DiscordClient, GuildRoleCreateEventArgs> GuildRoleCreated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildRoleCreateEventArgs> |
GuildRoleDeleted
Declaration
public event AsyncEventHandler<DiscordClient, GuildRoleDeleteEventArgs> GuildRoleDeleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildRoleDeleteEventArgs> |
GuildRoleUpdated
Declaration
public event AsyncEventHandler<DiscordClient, GuildRoleUpdateEventArgs> GuildRoleUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildRoleUpdateEventArgs> |
GuildUnavailable
Fired when a guild becomes unavailable.
Declaration
public event AsyncEventHandler<DiscordClient, GuildDeleteEventArgs> GuildUnavailable
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildDeleteEventArgs> |
GuildUpdated
Declaration
public event AsyncEventHandler<DiscordClient, GuildUpdateEventArgs> GuildUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, GuildUpdateEventArgs> |
Heartbeated
Fired on received heartbeat ACK.
Declaration
public event AsyncEventHandler<DiscordClient, HeartbeatEventArgs> Heartbeated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, HeartbeatEventArgs> |
InviteCreated
Fired when an invite is created. For this Event you need the GuildInvites intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, InviteCreateEventArgs> InviteCreated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, InviteCreateEventArgs> |
InviteDeleted
Fired when an invite is deleted. For this Event you need the GuildInvites intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, InviteDeleteEventArgs> InviteDeleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, InviteDeleteEventArgs> |
MessageCreated
Fired when a message is created. For this Event you need the GuildMessages intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, MessageCreateEventArgs> MessageCreated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageCreateEventArgs> |
MessageDeleted
Fired when a message is deleted. For this Event you need the GuildMessages intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, MessageDeleteEventArgs> MessageDeleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageDeleteEventArgs> |
MessageReactionAdded
Fired when a reaction gets added to a message. For this Event you need the GuildMessageReactions intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, MessageReactionAddEventArgs> MessageReactionAdded
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageReactionAddEventArgs> |
MessageReactionRemoved
Fired when a reaction gets removed from a message. For this Event you need the GuildMessageReactions intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, MessageReactionRemoveEventArgs> MessageReactionRemoved
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageReactionRemoveEventArgs> |
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
Declaration
public event AsyncEventHandler<DiscordClient, MessageReactionRemoveEmojiEventArgs> MessageReactionRemovedEmoji
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageReactionRemoveEmojiEventArgs> |
MessageReactionsCleared
Fired when all reactions get removed from a message. For this Event you need the GuildMessageReactions intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, MessageReactionsClearEventArgs> MessageReactionsCleared
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageReactionsClearEventArgs> |
MessagesBulkDeleted
Fired when multiple messages are deleted at once. For this Event you need the GuildMessages intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, MessageBulkDeleteEventArgs> MessagesBulkDeleted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageBulkDeleteEventArgs> |
MessageUpdated
Fired when a message is updated. For this Event you need the GuildMessages intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, MessageUpdateEventArgs> MessageUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, MessageUpdateEventArgs> |
PresenceUpdated
Fired when a presence has been updated. For this Event you need the GuildPresences intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, PresenceUpdateEventArgs> PresenceUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, PresenceUpdateEventArgs> |
Ready
Fired when the client enters ready state.
Declaration
public event AsyncEventHandler<DiscordClient, ReadyEventArgs> Ready
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, ReadyEventArgs> |
Resumed
Fired whenever a session is resumed.
Declaration
public event AsyncEventHandler<DiscordClient, ReadyEventArgs> Resumed
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, ReadyEventArgs> |
SocketClosed
Fired whenever WebSocket connection is terminated.
Declaration
public event AsyncEventHandler<DiscordClient, SocketCloseEventArgs> SocketClosed
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, SocketCloseEventArgs> |
SocketErrored
Fired whenever a WebSocket error occurs within the client.
Declaration
public event AsyncEventHandler<DiscordClient, SocketErrorEventArgs> SocketErrored
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, SocketErrorEventArgs> |
SocketOpened
Fired whenever WebSocket connection is established.
Declaration
public event AsyncEventHandler<DiscordClient, SocketEventArgs> SocketOpened
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, SocketEventArgs> |
TypingStarted
Fired when a user starts typing in a channel.
Declaration
public event AsyncEventHandler<DiscordClient, TypingStartEventArgs> TypingStarted
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, TypingStartEventArgs> |
UnknownEvent
Fired when an unknown event gets received.
Declaration
public event AsyncEventHandler<DiscordClient, UnknownEventArgs> UnknownEvent
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, UnknownEventArgs> |
UserSettingsUpdated
Fired when the current user updates their settings. For this Event you need the GuildPresences intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, UserSettingsUpdateEventArgs> UserSettingsUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, UserSettingsUpdateEventArgs> |
UserUpdated
Fired when properties about the current user change. For this Event you need the GuildPresences intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, UserUpdateEventArgs> UserUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, UserUpdateEventArgs> |
Remarks
NB: This event only applies for changes to the current user, the client that is connected to Discord.
VoiceServerUpdated
Fired when a guild's voice server is updated. For this Event you need the GuildVoiceStates intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, VoiceServerUpdateEventArgs> VoiceServerUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, VoiceServerUpdateEventArgs> |
VoiceStateUpdated
Fired when someone joins/leaves/moves voice channels. For this Event you need the GuildVoiceStates intent specified in Intents
Declaration
public event AsyncEventHandler<DiscordClient, VoiceStateUpdateEventArgs> VoiceStateUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, VoiceStateUpdateEventArgs> |
WebhooksUpdated
Fired whenever webhooks update.
Declaration
public event AsyncEventHandler<DiscordClient, WebhooksUpdateEventArgs> WebhooksUpdated
Event Type
Type | Description |
---|---|
AsyncEventHandler<DiscordClient, WebhooksUpdateEventArgs> |