Class DiscordClient
- Namespace
- DisCatSharp
- Assembly
- DisCatSharp.dll
A Discord API wrapper.
public sealed class DiscordClient : BaseDiscordClient, IDisposable
- Inheritance
-
DiscordClient
- Implements
- Inherited Members
Constructors
- DiscordClient(DiscordConfiguration)
Initializes a new instance of DiscordClient.
Properties
- CommandCooldownBuckets
Gets the cooldown buckets for commands.
- EmbeddedActivities
Gets the collection of presences held by this client.
- Emojis
Gets a dictionary of application emojis that this client has. The dictionary's key is the emoji ID.
- 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.
- Ping
Gets the websocket latency for this client.
- Presences
Gets the collection of presences held by this client.
- RegisteredEventhandlers
Gets all the registered event handlers.
- 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?, UserStatus?, DateTimeOffset?)
Connects to the gateway.
- CreateApplicationEmojiAsync(string, Stream)
Creates an application emoji.
- CreateGlobalApplicationCommandAsync(DiscordApplicationCommand)
Creates or overwrites a global application command.
- CreateGuildApplicationCommandAsync(ulong, DiscordApplicationCommand)
Creates or overwrites a guild application command.
- CreateGuildAsync(string, string, Optional<Stream>, VerificationLevel?, DefaultMessageNotifications?, SystemChannelFlags?)
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.
- CreateTestEntitlementsAsync(ulong, ulong, EntitlementOwnerType)
Creates a test entitlement.
- DeleteApplicationEmojiAsync(ulong)
Deletes an application emoji.
- DeleteGlobalApplicationCommandAsync(ulong)
Deletes a global application command.
- DeleteGuildApplicationCommandAsync(ulong, ulong)
Deletes a application command in a guild.
- DeleteTestEntitlementsAsync(ulong)
Deletes a test entitlement.
- DisconnectAsync()
Disconnects from the gateway.
- Dispose()
Disposes the client.
- EditGlobalApplicationCommandAsync(ulong, Action<ApplicationCommandEditModel>)
Edits a global application command.
- EditGuildApplicationCommandAsync(ulong, ulong, Action<ApplicationCommandEditModel>)
Edits a application command in a guild.
- ~DiscordClient()
Disposes the client.
- GenerateInAppOauthFor(DiscordUser, Permissions, OAuthScopes, string?, bool, ulong?, string?, string?, string?, bool, string?)
Generates an In-App OAuth Url for a specific
bot
.
- GetApplicationEmojiAsync(ulong, bool)
Gets an application emoji.
- GetApplicationEmojisAsync(bool)
Gets the application emojis.
Whether to ignore the cache. Defaults to false.
- GetChannelAsync(ulong, bool)
Gets a channel.
- GetConnectionsAsync()
Gets a list of user connections.
- GetCurrentApplicationInfoAsync()
Gets the current applications information.
- GetEntitlementsAsync(ulong?, ulong?)
Gets the applications entitlements.
- GetExtension<T>()
Retrieves a previously registered extension from this client.
- GetGlobalApplicationCommandAsync(ulong)
Gets a global application command by its id.
- GetGlobalApplicationCommandsAsync(bool)
Gets all the global application commands for this application.
- GetGuildApplicationCommandAsync(ulong, ulong)
Gets a application command in a guild by its id.
- GetGuildApplicationCommandsAsync(ulong, bool)
Gets all the application commands for a guild.
- GetGuildAsync(ulong, bool?, bool)
Gets a guild.
Setting
withCounts
to true will make a REST request.
- GetGuildPreviewAsync(ulong)
Gets a guild preview.
- GetGuildWidgetAsync(ulong)
Gets a guild widget.
- GetInAppOAuth(Permissions, OAuthScopes, string?, bool, ulong?, string?, string?, string?, bool, string?)
Gets the In-App OAuth Url for the current application.
- GetInviteByCodeAsync(string, bool?, bool?, ulong?)
Gets an invite.
- GetPublishedListingsAsync(ulong)
Gets the published store sku listings (premium application subscription).
- GetRoleConnectionMetadata()
Gets the applications role connection metadata.
- GetRpcApplicationAsync(ulong)
Gets a applications rpc information.
- GetSkusAsync()
Gets the applications skus.
- GetStickerAsync(ulong)
Gets a sticker.
- GetStickerPackAsync(ulong)
Gets a sticker pack.
- GetStickerPacksAsync()
Gets all nitro sticker packs.
- GetTemplateAsync(string)
Gets a guild template by the code.
- GetThreadAsync(ulong, bool)
Gets a thread.
- GetUserAsync(ulong, bool)
Gets a user.
- GetWebhookAsync(ulong)
Gets a webhook.
- GetWebhookWithTokenAsync(ulong, string)
Gets a webhook with a token.
- ListDefaultSoundboardSoundsAsync()
Gets all default soundboard sounds available for all users.
- ModifyApplicationEmojiAsync(ulong, string)
Modifies an application emoji.
- ReconnectAsync(bool)
Reconnects to the gateway.
- RegisterEventHandler(object, bool)
Registers all methods annotated with EventAttribute from the given object.
- RegisterEventHandler(Type)
If abstract, registers all static methods of the type.
If non-abstract, tries to instantiate it, optionally using the provided ServiceProvider and registers all instance and static methods.
- RegisterEventHandlers(Assembly)
Registers all types associated with the provided assembly that have the EventHandler attribute.
- RegisterStaticEventHandler(Type)
Registers all static methods annotated with EventAttribute from the given type.
- RemoveGlobalApplicationCommandsAsync()
Removes all global application commands.
- RemoveGuildApplicationCommandsAsync(DiscordGuild)
Removes all global application commands for a specific guild.
- RemoveGuildApplicationCommandsAsync(ulong)
Removes all global application commands for a specific guild id.
- RequestAndWaitForSoundboardSoundsAsync(IEnumerable<ulong>)
Requests and waits for guild soundboard sounds.
- RequestSoundboardSoundsAsync(IEnumerable<ulong>)
Requests soundboard sounds over the gateway.
- SendMessageAsync(DiscordChannel, DiscordEmbed)
Sends a message with an embed.
- SendMessageAsync(DiscordChannel, DiscordMessageBuilder)
Sends a message with the DiscordMessageBuilder.
- SendMessageAsync(DiscordChannel, Action<DiscordMessageBuilder>)
Sends a message with an Action<T>.
- SendMessageAsync(DiscordChannel, string)
Sends a normal message.
- SendMessageAsync(DiscordChannel, string, DiscordEmbed)
Sends a message with content and an embed.
- TryGetChannel(ulong, out DiscordChannel?, bool)
Tries to get a channel.
- TryGetGuild(ulong, out DiscordGuild?, bool?, bool)
Tries to get a guild.
Setting
withCounts
to true will make a REST request.
- TryGetGuildPreview(ulong, out DiscordGuildPreview?)
Tries to get a guild preview.
- TryGetGuildWidget(ulong, out DiscordWidget?)
Tries to get a guild widget.
- TryGetInviteByCode(string, out DiscordInvite?, bool?, bool?, ulong?)
Tries to get an invite.
- TryGetSticker(ulong, out DiscordSticker?)
Tries to get a sticker.
- TryGetThread(ulong, out DiscordThreadChannel?, bool)
Tries to get a thread.
- TryGetUser(ulong, out DiscordUser?, bool)
Tries to get a user.
- TryGetWebhook(ulong, out DiscordWebhook?)
Tries to get a webhook.
- TryGetWebhookWithToken(ulong, string, out DiscordWebhook?)
Tries to get a webhook with a token.
- UnregisterEventHandler(object, bool)
Perfectly mirrors RegisterEventHandler(object, bool).
- UnregisterEventHandler(Type)
Perfectly mirrors RegisterEventHandler(Type).
- UnregisterEventHandler<T>()
Perfectly mirrors RegisterEventHandler<T>().
- UnregisterEventHandlers(Assembly)
Perfectly mirrors RegisterEventHandlers(Assembly).
- UnregisterStaticEventHandler(Type)
Perfectly mirrors RegisterStaticEventHandler(Type).
- UnregisterStaticEventHandler<T>()
Perfectly mirrors RegisterStaticEventHandler<T>().
- UpdateCurrentUserAsync(string?, Optional<Stream?>, Optional<Stream?>)
Edits current user.
- UpdateRoleConnectionMetadata(IEnumerable<DiscordApplicationRoleConnectionMetadata>)
Updates the applications role connection metadata.
- UpdateStatusAsync(DiscordActivity, UserStatus?, DateTimeOffset?)
Updates current user's activity and status.
Events
- ApplicationCommandCreated
Fired when a new application command is registered.
- ApplicationCommandDeleted
Fired when an application command is deleted.
- ApplicationCommandPermissionsUpdated
Fired when application command permissions gets updated.
- ApplicationCommandUpdated
Fired when an application command is updated.
- AutomodActionExecuted
Fired when a rule is triggered and an action is executed.
- AutomodRuleCreated
Fired when an auto mod rule gets created.
- AutomodRuleDeleted
Fired when an auto mod rule gets deleted.
- AutomodRuleUpdated
Fired when an auto mod rule gets 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
- EmbeddedActivityUpdated
Fired when a embedded activity has been updated.
- EntitlementCreated
Fired when an entitlement was created.
- EntitlementDeleted
Fired when an entitlement was deleted.
- EntitlementUpdated
Fired when an entitlement was updated.
- GuildApplicationCommandCountUpdated
Fired when a new application command is registered.
- GuildAuditLogEntryCreated
Fired when a guild audit log entry was created. Requires bot to have the ViewAuditLog permission.
- 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
- GuildIntegrationCreated
Fired when a guild integration is created. For this Event you need the GuildIntegrations intent specified in Intents
- GuildIntegrationDeleted
Fired when a guild integration is deleted. For this Event you need the GuildIntegrations intent specified in Intents
- GuildIntegrationUpdated
Fired when a guild integration is updated. For this Event you need the GuildIntegrations 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
- GuildMemberTimeoutAdded
Fired when a guild member timeout gets added. For this Event you need the GuildModeration intent specified in Intents
- GuildMemberTimeoutChanged
Fired when a guild member timeout gets changed. For this Event you need the GuildMembers intent specified in Intents
- GuildMemberTimeoutRemoved
Fired when a guild member timeout gets removed. 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
- GuildScheduledEventCreated
Fired when a scheduled Event is created. For this Event you need the GuildScheduledEvents intent specified in Intents
- GuildScheduledEventDeleted
Fired when a scheduled Event is deleted. For this Event you need the GuildScheduledEvents intent specified in Intents
- GuildScheduledEventUpdated
Fired when a scheduled Event is updated. For this Event you need the GuildScheduledEvents intent specified in Intents
- GuildScheduledEventUserAdded
Fired when a user subscribes to a scheduled event. For this Event you need the GuildScheduledEvents intent specified in Intents
- GuildScheduledEventUserRemoved
Fired when a user unsubscribes from a scheduled event. For this Event you need the GuildScheduledEvents intent specified in Intents
- GuildSoundboardSoundCreated
Fired when a guild soundboard sound is created. For this Event you need the GuildExpressions intent specified in Intents
- GuildSoundboardSoundDeleted
Fired when a guild soundboard sound is deleted. For this Event you need the Guilds intent specified in Intents
- GuildSoundboardSoundUpdated
Fired when a guild soundboard sound is updated. For this Event you need the Guilds intent specified in Intents
- GuildSoundboardSoundsUpdated
Fired when guild soundboard sounds is updated. For this Event you need the Guilds intent specified in Intents
- GuildStickersUpdated
Fired when a guilds stickers get updated For this Event you need the GuildEmojisAndStickers intent specified in Intents
- 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.
- 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
- MessageAcknowledged
Fired when message is acknowledged by the user. For this Event you need the GuildMessages 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
- MessagePollVoteAdded
Fired when a message poll vote is added. For this Event you need the GuildMessagePolls and DirectMessagePolls intent (depending on where u want to receive events from) specified in Intents.
- MessagePollVoteRemoved
Fired when a message poll vote is removed. For this Event you need the GuildMessagePolls and DirectMessagePolls intent (depending on where u want to receive events from) 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
- PayloadReceived
Fired when a gateway payload is received. Only fired when EnableLibraryDeveloperMode or EnablePayloadReceivedEvent is enabled.
- PresenceUpdated
Fired when a presence has been updated. For this Event you need the GuildPresences intent specified in Intents
- RateLimitHit
Fired when a ratelimit was hit.
- Ready
Fired when the client enters ready state.
- Resumed
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.
- SoundboardSounds
Fired in response to RequestSoundboardSoundsAsync(IEnumerable<ulong>).
- StageInstanceCreated
Fired when a Stage Instance is created. For this Event you need the Guilds intent specified in Intents
- StageInstanceDeleted
Fired when a Stage Instance is deleted. For this Event you need the Guilds intent specified in Intents
- StageInstanceUpdated
Fired when a Stage Instance is updated. For this Event you need the Guilds intent specified in Intents
- 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 a thread member is updated. For this Event you need the Guilds intent specified in Intents
- ThreadMemberUpdated
Fired when a thread member 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.
- VoiceChannelEffectSend
Fired when a voice channel effect was send. For this Event you need the GuildVoiceStates intent specified in Intents
- VoiceChannelStatusUpdated
Fired whenever a voice channel's status is updated. For this Event you need the Guilds intent specified in Intents
- 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.