Class ShardedGatewayClient
public sealed class ShardedGatewayClient : IReadOnlyList<GatewayClient>, IReadOnlyCollection<GatewayClient>, IEnumerable<GatewayClient>, IEnumerable, IEntity, IDisposable
- Inheritance
-
ShardedGatewayClient
- Implements
- Inherited Members
Constructors
ShardedGatewayClient(IEntityToken, ShardedGatewayClientConfiguration?)
public ShardedGatewayClient(IEntityToken token, ShardedGatewayClientConfiguration? configuration = null)
Parameters
token
IEntityTokenconfiguration
ShardedGatewayClientConfiguration
Properties
Count
The count of shards of the ShardedGatewayClient.
public int Count { get; }
Property Value
CreatedAt
The time this object was created.
public DateTimeOffset CreatedAt { get; }
Property Value
Id
The unique identifier for this object.
public ulong Id { get; }
Property Value
this[int]
public GatewayClient this[int shardId] { get; }
Parameters
shardId
int
Property Value
this[ulong]
public GatewayClient this[ulong guildId] { get; }
Parameters
guildId
ulong
Property Value
Rest
The RestClient of the ShardedGatewayClient.
public RestClient Rest { get; }
Property Value
Token
The Token of the ShardedGatewayClient.
public IEntityToken Token { get; }
Property Value
Methods
CloseAsync(WebSocketCloseStatus)
public Task CloseAsync(WebSocketCloseStatus status = WebSocketCloseStatus.NormalClosure)
Parameters
status
WebSocketCloseStatus
Returns
Dispose()
public void Dispose()
GetEnumerator()
public IEnumerator<GatewayClient> GetEnumerator()
Returns
StartAsync(Func<Shard, PresenceProperties?>?)
public Task StartAsync(Func<Shard, PresenceProperties?>? presenceFactory = null)
Parameters
presenceFactory
Func<Shard, PresenceProperties>
Returns
Events
ApplicationCommandPermissionsUpdate
Sent when an application command's permissions are updated. The inner payload is an ApplicationCommandPermission object.
public event Func<GatewayClient, ApplicationCommandPermission, ValueTask>? ApplicationCommandPermissionsUpdate
Event Type
Remarks
Required Intents: None
Optional Intents: None
AutoModerationActionExecution
Sent when a rule is triggered and an action is executed (e.g. when a message is blocked).
public event Func<GatewayClient, AutoModerationActionExecutionEventArgs, ValueTask>? AutoModerationActionExecution
Event Type
Remarks
Required Intents: AutoModerationExecution
Optional Intents:
- MessageContent For receiving Content and MatchedContent.
AutoModerationRuleCreate
Sent when a rule is created.
The inner payload is an AutoModerationRule object.
public event Func<GatewayClient, AutoModerationRule, ValueTask>? AutoModerationRuleCreate
Event Type
Remarks
Required Intents: AutoModerationConfiguration
Optional Intents: None
AutoModerationRuleDelete
Sent when a rule is deleted.
The inner payload is an AutoModerationRule object.
public event Func<GatewayClient, AutoModerationRule, ValueTask>? AutoModerationRuleDelete
Event Type
Remarks
Required Intents: AutoModerationConfiguration
Optional Intents: None
AutoModerationRuleUpdate
Sent when a rule is updated.
The inner payload is an AutoModerationRule object.
public event Func<GatewayClient, AutoModerationRule, ValueTask>? AutoModerationRuleUpdate
Event Type
Remarks
Required Intents: AutoModerationConfiguration
Optional Intents: None
ChannelPinsUpdate
Sent when a message is pinned or unpinned in a text channel. This is not sent when a pinned message is deleted.
public event Func<GatewayClient, ChannelPinsUpdateEventArgs, ValueTask>? ChannelPinsUpdate
Event Type
Remarks
Required Intents: Guilds, DirectMessages
Optional Intents: None
Close
public event Func<GatewayClient, ValueTask>? Close
Event Type
Connect
public event Func<GatewayClient, ValueTask>? Connect
Event Type
Connecting
public event Func<GatewayClient, ValueTask>? Connecting
Event Type
CurrentUserUpdate
Sent when properties about the current bot's user change.
Inner payload is a CurrentUser object.
public event Func<GatewayClient, CurrentUser, ValueTask>? CurrentUserUpdate
Event Type
Remarks
Required Intents: None
Optional Intents: None
Disconnect
public event Func<GatewayClient, bool, ValueTask>? Disconnect
Event Type
EntitlementCreate
Sent when an entitlement is created.
The inner payload is an Entitlement object.
public event Func<GatewayClient, Entitlement, ValueTask>? EntitlementCreate
Event Type
Remarks
Required Intents: None
Optional Intents: None
EntitlementDelete
Sent when an entitlement is deleted. Entitlements are not deleted when they expire.
The inner payload is an Entitlement object.
public event Func<GatewayClient, Entitlement, ValueTask>? EntitlementDelete
Event Type
Remarks
Required Intents: None
Optional Intents: None
EntitlementUpdate
Sent when an entitlement is updated. When an entitlement for a subscription is renewed, the EndsAt field may have an updated value with the new expiration date.
The inner payload is an Entitlement object.
public event Func<GatewayClient, Entitlement, ValueTask>? EntitlementUpdate
Event Type
Remarks
Required Intents: None
Optional Intents: None
GuildAuditLogEntryCreate
Sent when a guild audit log entry is created.
The inner payload is an AuditLogEntry object. This event is only sent to bots with the ViewAuditLog permission.
public event Func<GatewayClient, AuditLogEntry, ValueTask>? GuildAuditLogEntryCreate
Event Type
Remarks
Required Intents: GuildModeration
Optional Intents: None
GuildBanAdd
Sent when a user is banned from a guild.
public event Func<GatewayClient, GuildBanEventArgs, ValueTask>? GuildBanAdd
Event Type
Remarks
Required Intents: GuildModeration
Optional Intents: None
GuildBanRemove
Sent when a user is unbanned from a guild.
public event Func<GatewayClient, GuildBanEventArgs, ValueTask>? GuildBanRemove
Event Type
Remarks
Required Intents: GuildModeration
Optional Intents: None
GuildChannelCreate
Sent when a new guild channel is created, relevant to the bot.
The inner payload is an IGuildChannel object.
public event Func<GatewayClient, IGuildChannel, ValueTask>? GuildChannelCreate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildChannelDelete
Sent when a channel relevant to the bot is deleted.
The inner payload is an IGuildChannel object.
public event Func<GatewayClient, IGuildChannel, ValueTask>? GuildChannelDelete
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildChannelUpdate
Sent when a channel is updated. This is not sent with new messages, those are tracked by MessageCreate and GuildThreadCreate. This event may reference roles or guild members that no longer exist in the guild.
The inner payload is an IGuildChannel object.
public event Func<GatewayClient, IGuildChannel, ValueTask>? GuildChannelUpdate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildCreate
This event can be sent in three different scenarios (During an outage, the Guild object in scenarios 1 and 3 may be marked as unavailable):
- To lazily load and backfill information for all unavailable guilds sent in the Ready event. Guilds unavailable due to an outage will send a GuildDelete event.
- When a guild becomes available again to the client.
- When the current user joins a new guild.
public event Func<GatewayClient, GuildCreateEventArgs, ValueTask>? GuildCreate
Event Type
Remarks
The inner payload can be a Guild object with extra fields, or an unavailable Guild object. If the guild has over 75k users, users and presences returned in this event will only contain your bot and users in voice channels.
Required Intents: Guilds
Optional Intents:
- GuildPresences For receiving users and presences other than the bot's user and users in voice channels (Same as the 75k limit).
GuildDelete
Sent when a guild becomes or was already unavailable due to an outage, or when the bot leaves / is removed from a guild.
public event Func<GatewayClient, GuildDeleteEventArgs, ValueTask>? GuildDelete
Event Type
Remarks
The inner payload is an unavailable guild object. If the IsUserDeleted field is not true, the bot was removed from the guild.
Required Intents: Guilds
Optional Intents: None
GuildEmojisUpdate
Sent when a guild's emojis have been updated.
public event Func<GatewayClient, GuildEmojisUpdateEventArgs, ValueTask>? GuildEmojisUpdate
Event Type
Remarks
Required Intents: GuildEmojisAndStickers
Optional Intents: None
GuildIntegrationCreate
Sent when an integration is created.
The inner payload is an integration object with a set GuildId.
public event Func<GatewayClient, GuildIntegrationEventArgs, ValueTask>? GuildIntegrationCreate
Event Type
Remarks
Required Intents: GuildIntegrations
Optional Intents: None
GuildIntegrationDelete
Sent when an integration is deleted.
public event Func<GatewayClient, GuildIntegrationDeleteEventArgs, ValueTask>? GuildIntegrationDelete
Event Type
Remarks
Required Intents: GuildIntegrations
Optional Intents: None
GuildIntegrationUpdate
Sent when an integration is updated.
The inner payload is an integration object with a set GuildId.
public event Func<GatewayClient, GuildIntegrationEventArgs, ValueTask>? GuildIntegrationUpdate
Event Type
Remarks
Required Intents: GuildIntegrations
Optional Intents: None
GuildIntegrationsUpdate
Sent when guild integrations are updated.
public event Func<GatewayClient, GuildIntegrationsUpdateEventArgs, ValueTask>? GuildIntegrationsUpdate
Event Type
Remarks
Required Intents: GuildIntegrations
Optional Intents: None
GuildJoinRequestDelete
Not documented by Discord.
public event Func<GatewayClient, GuildJoinRequestDeleteEventArgs, ValueTask>? GuildJoinRequestDelete
Event Type
GuildJoinRequestUpdate
Not documented by Discord.
public event Func<GatewayClient, GuildJoinRequestUpdateEventArgs, ValueTask>? GuildJoinRequestUpdate
Event Type
GuildScheduledEventCreate
Sent when a guild scheduled event is created.
The inner payload is a GuildScheduledEvent object.
public event Func<GatewayClient, GuildScheduledEvent, ValueTask>? GuildScheduledEventCreate
Event Type
Remarks
Required Intents: GuildScheduledEvents
Optional Intents: None
GuildScheduledEventDelete
Sent when a guild scheduled event is deleted.
The inner payload is a GuildScheduledEvent object.
public event Func<GatewayClient, GuildScheduledEvent, ValueTask>? GuildScheduledEventDelete
Event Type
Remarks
Required Intents: GuildScheduledEvents
Optional Intents: None
GuildScheduledEventUpdate
Sent when a guild scheduled event is updated.
The inner payload is a GuildScheduledEvent object.
public event Func<GatewayClient, GuildScheduledEvent, ValueTask>? GuildScheduledEventUpdate
Event Type
Remarks
Required Intents: GuildScheduledEvents
Optional Intents: None
GuildScheduledEventUserAdd
Sent when a user has subscribed to a guild scheduled event.
public event Func<GatewayClient, GuildScheduledEventUserEventArgs, ValueTask>? GuildScheduledEventUserAdd
Event Type
Remarks
Required Intents: GuildScheduledEvents
Optional Intents: None
GuildScheduledEventUserRemove
Sent when a user has unsubscribed from a guild scheduled event.
public event Func<GatewayClient, GuildScheduledEventUserEventArgs, ValueTask>? GuildScheduledEventUserRemove
Event Type
Remarks
Required Intents: GuildScheduledEvents
Optional Intents: None
GuildStickersUpdate
Sent when a guild's stickers have been updated.
public event Func<GatewayClient, GuildStickersUpdateEventArgs, ValueTask>? GuildStickersUpdate
Event Type
Remarks
Required Intents: GuildEmojisAndStickers
Optional Intents: None
GuildThreadCreate
Sent when a thread is created, relevant to the bot, or when the current user is added to a thread.
The inner payload is an IGuildChannel object.
public event Func<GatewayClient, GuildThreadCreateEventArgs, ValueTask>? GuildThreadCreate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildThreadDelete
Sent when a thread relevant to the bot is deleted.
The inner payload is a subset of an IGuildChannel object.
public event Func<GatewayClient, GuildThreadDeleteEventArgs, ValueTask>? GuildThreadDelete
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildThreadListSync
Sent when the current user gains access to a channel.
public event Func<GatewayClient, GuildThreadListSyncEventArgs, ValueTask>? GuildThreadListSync
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildThreadUpdate
Sent when a thread is updated. This is not sent with new messages, those are tracked by MessageCreate.
The inner payload is an IGuildChannel object.
public event Func<GatewayClient, GuildThread, ValueTask>? GuildThreadUpdate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildThreadUserUpdate
Sent when the GuildThreadUser object for the bot is updated. This event is largely just a signal that you are a member of the thread.
The inner payload is a GuildThreadUserUpdateEventArgs object with a set GuildId.
public event Func<GatewayClient, GuildThreadUserUpdateEventArgs, ValueTask>? GuildThreadUserUpdate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildThreadUsersUpdate
Sent when anyone is added to or removed from a thread.
public event Func<GatewayClient, GuildThreadUsersUpdateEventArgs, ValueTask>? GuildThreadUsersUpdate
Event Type
Remarks
Required Intents: Guilds, GuildUsers*
Optional Intents:
- GuildUsers For receiving this event when other users are added / removed, otherwise this event will only fire for the bot's user.
*Must also be enabled in the developer portal.
GuildUpdate
Sent when a guild is updated.
The inner payload is a Guild object.
public event Func<GatewayClient, Guild, ValueTask>? GuildUpdate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
GuildUserAdd
Sent when a new user joins a guild.
The inner payload is a GuildUser object with an extra guild_id
key.
public event Func<GatewayClient, GuildUser, ValueTask>? GuildUserAdd
Event Type
Remarks
Required Intents: GuildUsers*
Optional Intents: None
*Must also be enabled in the developer portal.
GuildUserChunk
Sent in response to RequestGuildUsersAsync(GuildUsersRequestProperties, WebSocketPayloadProperties?, CancellationToken). You can use the ChunkIndex and ChunkCount to calculate how many chunks are left for your request.
public event Func<GatewayClient, GuildUserChunkEventArgs, ValueTask>? GuildUserChunk
Event Type
Remarks
Required Intents: None
Optional Intents: None
GuildUserRemove
Sent when a user is removed from a guild (leave/kick/ban).
public event Func<GatewayClient, GuildUserRemoveEventArgs, ValueTask>? GuildUserRemove
Event Type
Remarks
Required Intents: GuildUsers*
Optional Intents: None
*Must also be enabled in the developer portal.
GuildUserUpdate
Sent when a guild user is updated. This will also fire when the GuildUser object of a guild user changes.
public event Func<GatewayClient, GuildUser, ValueTask>? GuildUserUpdate
Event Type
Remarks
Required Intents: GuildUsers*
Optional Intents: None
*Must also be enabled in the developer portal.
InteractionCreate
Sent when a user uses an interaction.
Inner payload is an Interaction.
public event Func<GatewayClient, Interaction, ValueTask>? InteractionCreate
Event Type
Remarks
Required Intents: None
Optional Intents: None
InviteCreate
Sent when a new invite to a channel is created. Only sent if the bot has the ManageChannels permission for the relevant channel.
public event Func<GatewayClient, Invite, ValueTask>? InviteCreate
Event Type
Remarks
Required Intents: GuildInvites
Optional Intents: None
InviteDelete
Sent when an invite is deleted. Only sent if the bot has the ManageChannels permission for the relevant channel.
public event Func<GatewayClient, InviteDeleteEventArgs, ValueTask>? InviteDelete
Event Type
Remarks
Required Intents: GuildInvites
Optional Intents: None
LatencyUpdate
public event Func<GatewayClient, TimeSpan, ValueTask>? LatencyUpdate
Event Type
Log
public event Func<GatewayClient, LogMessage, ValueTask>? Log
Event Type
MessageCreate
Sent when a message is created.
The inner payload is a message object with set GuildId, and Author fields.
public event Func<GatewayClient, Message, ValueTask>? MessageCreate
Event Type
Remarks
Required Intents: GuildMessages, DirectMessages*
Optional Intents:
- MessageContent
For receiving Content, Embeds, Attachments and Embeds.
This does not apply to:- Content in messages sent by the bot.
- Content in DMs with the bot.
- Content in which the bot is mentioned.
- Content of messages a message context menu command is used on.
*Ephemeral messages do not use the guild channel. Because of this, they are tied to the DirectMessages intent, and the message object won't include a GuildId or Author.
MessageDelete
Sent when a message is deleted.
public event Func<GatewayClient, MessageDeleteEventArgs, ValueTask>? MessageDelete
Event Type
Remarks
Required Intents: GuildMessages, DirectMessages
Optional Intents: None
MessageDeleteBulk
Sent when multiple messages are deleted at once.
public event Func<GatewayClient, MessageDeleteBulkEventArgs, ValueTask>? MessageDeleteBulk
Event Type
Remarks
Required Intents: GuildMessages
Optional Intents: None
MessagePollVoteAdd
public event Func<GatewayClient, MessagePollVoteEventArgs, ValueTask>? MessagePollVoteAdd
Event Type
MessagePollVoteRemove
public event Func<GatewayClient, MessagePollVoteEventArgs, ValueTask>? MessagePollVoteRemove
Event Type
MessageReactionAdd
Sent when a user adds a reaction to a message.
public event Func<GatewayClient, MessageReactionAddEventArgs, ValueTask>? MessageReactionAdd
Event Type
Remarks
Required Intents: GuildMessageReactions, DirectMessageReactions
Optional Intents: None
MessageReactionRemove
Sent when a user removes a reaction from a message.
public event Func<GatewayClient, MessageReactionRemoveEventArgs, ValueTask>? MessageReactionRemove
Event Type
Remarks
Required Intents: GuildMessageReactions, DirectMessageReactions
Optional Intents: None
MessageReactionRemoveAll
Sent when a user explicitly removes all reactions from a message.
public event Func<GatewayClient, MessageReactionRemoveAllEventArgs, ValueTask>? MessageReactionRemoveAll
Event Type
Remarks
Required Intents: GuildMessageReactions, DirectMessageReactions
Optional Intents: None
MessageReactionRemoveEmoji
Sent when a user removes all instances of a given emoji from the reactions of a message.
public event Func<GatewayClient, MessageReactionRemoveEmojiEventArgs, ValueTask>? MessageReactionRemoveEmoji
Event Type
Remarks
Required Intents: GuildMessageReactions, DirectMessageReactions
Optional Intents: None
MessageUpdate
Sent when a message is updated.
The inner payload is a message object with set GuildId, and Author fields.
public event Func<GatewayClient, Message, ValueTask>? MessageUpdate
Event Type
Remarks
Required Intents: GuildMessages, DirectMessages*
Optional Intents:
- MessageContent
For receiving Content, Embeds, Attachments and Embeds.
This does not apply to:- Content in messages sent by the bot.
- Content in DMs with the bot.
- Content in which the bot is mentioned.
- Content of messages a message context menu command is used on.
*Ephemeral messages do not use the guild channel. Because of this, they are tied to the DirectMessages intent, and the message object won't include a GuildId or Author.
PresenceUpdate
Sent when a user's presence or info, such as their name or avatar, is updated. Requires the GuildPresences intent.
The user object within this event can be partial, with the ID being the only required field, everything else is optional. Along with this limitation, no fields are required, and the types of the fields are not validated. You should expect any combination of fields and types within this event.
public event Func<GatewayClient, Presence, ValueTask>? PresenceUpdate
Event Type
Remarks
Required Intents: GuildPresences*
Optional Intents: None
*Must also be enabled in the developer portal.
Ready
The ready event is dispatched when a client has completed the initial handshake with the Gateway (for new sessions). The ready event contains all the state required for a client to begin interacting with the rest of the platform.
public event Func<GatewayClient, ReadyEventArgs, ValueTask>? Ready
Event Type
Remarks
Required Intents: None
Optional Intents: None
Resume
public event Func<GatewayClient, ValueTask>? Resume
Event Type
RoleCreate
Sent when a guild role is created.
public event Func<GatewayClient, Role, ValueTask>? RoleCreate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
RoleDelete
Sent when a guild role is deleted.
public event Func<GatewayClient, RoleDeleteEventArgs, ValueTask>? RoleDelete
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
RoleUpdate
Sent when a guild role is updated.
public event Func<GatewayClient, Role, ValueTask>? RoleUpdate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
StageInstanceCreate
Sent when a StageInstance is created (i.e. the Stage is now 'live').
Inner payload is a StageInstance.
public event Func<GatewayClient, StageInstance, ValueTask>? StageInstanceCreate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
StageInstanceDelete
Sent when a StageInstance is deleted (i.e. the Stage has been closed).
Inner payload is a StageInstance.
public event Func<GatewayClient, StageInstance, ValueTask>? StageInstanceDelete
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
StageInstanceUpdate
Sent when a StageInstance is updated.
Inner payload is a StageInstance.
public event Func<GatewayClient, StageInstance, ValueTask>? StageInstanceUpdate
Event Type
Remarks
Required Intents: Guilds
Optional Intents: None
TypingStart
Sent when a user starts typing in a channel, and fires again every 10 seconds while they continue typing.
public event Func<GatewayClient, TypingStartEventArgs, ValueTask>? TypingStart
Event Type
Remarks
Required Intents: GuildMessageTyping, DirectMessageTyping
Optional Intents: None
UnknownEvent
An unknown event.
public event Func<GatewayClient, UnknownEventEventArgs, ValueTask>? UnknownEvent
Event Type
VoiceChannelEffectSend
Sent when someone sends an effect, such as an emoji reaction or a soundboard sound, in a voice channel the current user is connected to.
Inner payload is a VoiceChannelEffectSendEventArgs object.
public event Func<GatewayClient, VoiceChannelEffectSendEventArgs, ValueTask>? VoiceChannelEffectSend
Event Type
Remarks
Required Intents: GuildVoiceStates
Optional Intents: None
VoiceServerUpdate
Sent when a guild's voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.
public event Func<GatewayClient, VoiceServerUpdateEventArgs, ValueTask>? VoiceServerUpdate
Event Type
Remarks
Required Intents: None
Optional Intents: None
VoiceStateUpdate
Sent when someone joins/leaves/moves voice channels.
Inner payload is a VoiceState object.
public event Func<GatewayClient, VoiceState, ValueTask>? VoiceStateUpdate
Event Type
Remarks
Required Intents: GuildVoiceStates
Optional Intents: None
WebhooksUpdate
Sent when a guild channel's webhook is created, updated, or deleted.
public event Func<GatewayClient, WebhooksUpdateEventArgs, ValueTask>? WebhooksUpdate
Event Type
Remarks
Required Intents: GuildWebhooks
Optional Intents: None