Class BaseSocketClient
Represents the base of a WebSocket-based Discord client.
Inherited Members
Namespace: Discord.WebSocket
Assembly: Discord.Net.WebSocket.dll
Syntax
public abstract class BaseSocketClient : BaseDiscordClient, IDiscordClient, IDisposable, IAsyncDisposable
Fields
| Improve this Doc View SourceBaseConfig
Declaration
protected readonly DiscordSocketConfig BaseConfig
Field Value
Type | Description |
---|---|
DiscordSocketConfig |
Properties
| Improve this Doc View SourceActivity
Gets the activity for the logged-in user.
Declaration
public abstract IActivity Activity { get; protected set; }
Property Value
Type | Description |
---|---|
IActivity | An activity object that represents the user's current activity. |
CurrentUser
Gets the current logged-in user.
Declaration
public virtual SocketSelfUser CurrentUser { get; protected set; }
Property Value
Type | Description |
---|---|
SocketSelfUser |
DefaultStickerPacks
Gets a collection of default stickers.
Declaration
public abstract IReadOnlyCollection<StickerPack<SocketSticker>> DefaultStickerPacks { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<StickerPack<SocketSticker>> |
Guilds
Gets a collection of guilds that the user is currently in.
Declaration
public abstract IReadOnlyCollection<SocketGuild> Guilds { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<SocketGuild> | A read-only collection of guilds that the current user is in. |
Latency
Gets the estimated round-trip latency, in milliseconds, to the gateway server.
Declaration
public abstract int Latency { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 | An |
PrivateChannels
Gets a collection of private channels opened in this session.
Declaration
public abstract IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<ISocketPrivateChannel> | A read-only collection of private channels that the user currently partakes in. |
Remarks
This method will retrieve all private channels (including direct-message, group channel and such) that are currently opened in this session.
warning
This method will not return previously opened private channels outside of the current session! If you have just started the client, this may return an empty collection.
Rest
Provides access to a REST-only client with a shared state from this client.
Declaration
public abstract DiscordSocketRestClient Rest { get; }
Property Value
Type | Description |
---|---|
DiscordSocketRestClient |
Status
Gets the status for the logged-in user.
Declaration
public abstract UserStatus Status { get; protected set; }
Property Value
Type | Description |
---|---|
UserStatus | A status object that represents the user's online presence status. |
Methods
| Improve this Doc View SourceCreateGuildAsync(String, IVoiceRegion, Stream, RequestOptions)
Creates a guild for the logged-in user who is in less than 10 active guilds.
Declaration
public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the new guild. |
IVoiceRegion | region | The voice region to create the guild with. |
Stream | jpegIcon | The icon of the guild. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<RestGuild> | A task that represents the asynchronous creation operation. The task result contains the created guild. |
Remarks
This method creates a new guild on behalf of the logged-in user.
warning
Due to Discord's limitation, this method will only work for users that are in less than 10 guilds.
DownloadUsersAsync(IEnumerable<IGuild>)
Attempts to download users into the user cache for the selected guilds.
Declaration
public abstract Task DownloadUsersAsync(IEnumerable<IGuild> guilds)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IGuild> | guilds | The guilds to download the members from. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous download operation. |
GetApplicationInfoAsync(RequestOptions)
Gets a Discord application information for the logged-in user.
Declaration
public abstract Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<RestApplication> | A task that represents the asynchronous get operation. The task result contains the application information. |
Remarks
This method reflects your application information you submitted when creating a Discord application via the Developer Portal.
GetChannel(UInt64)
Gets a channel.
Declaration
public abstract SocketChannel GetChannel(ulong id)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id | The snowflake identifier of the channel (e.g. |
Returns
Type | Description |
---|---|
SocketChannel | A generic WebSocket-based channel object (voice, text, category, etc.) associated with the identifier; null when the channel cannot be found. |
GetConnectionsAsync(RequestOptions)
Gets the connections that the user has set up.
Declaration
public Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestConnection>> | A task that represents the asynchronous get operation. The task result contains a read-only collection of connections. |
GetGuild(UInt64)
Gets a guild.
Declaration
public abstract SocketGuild GetGuild(ulong id)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id | The guild snowflake identifier. |
Returns
Type | Description |
---|---|
SocketGuild | A WebSocket-based guild associated with the snowflake identifier; null when the guild cannot be found. |
GetInviteAsync(String, RequestOptions, Nullable<UInt64>)
Gets an invite.
Declaration
public Task<RestInviteMetadata> GetInviteAsync(string inviteId, RequestOptions options = null, ulong? scheduledEventId = null)
Parameters
Type | Name | Description |
---|---|---|
String | inviteId | The invitation identifier. |
RequestOptions | options | The options to be used when sending the request. |
Nullable<UInt64> | scheduledEventId | The id of the guild scheduled event to include with the invite. |
Returns
Type | Description |
---|---|
Task<RestInviteMetadata> | A task that represents the asynchronous get operation. The task result contains the invite information. |
GetStickerAsync(UInt64, CacheMode, RequestOptions)
Gets a sticker.
Declaration
public abstract Task<SocketSticker> GetStickerAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id | The id of the sticker to get. |
CacheMode | mode | Whether or not to allow downloading from the api. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<SocketSticker> | A SocketSticker if found, otherwise null. |
GetUser(String, String)
Gets a user.
Declaration
public abstract SocketUser GetUser(string username, string discriminator = null)
Parameters
Type | Name | Description |
---|---|---|
String | username | The name of the user. |
String | discriminator | The discriminator value of the user. |
Returns
Type | Description |
---|---|
SocketUser | A generic WebSocket-based user; null when the user cannot be found. |
Remarks
This method gets the user present in the WebSocket cache with the given condition.
warning
Sometimes a user may return null due to Discord not sending offline users in large guilds (i.e. guild with 100+ members) actively. To download users on startup and to see more information about this subject, see AlwaysDownloadUsers.
note
This method does not attempt to fetch users that the logged-in user does not have access to (i.e.
users who don't share mutual guild(s) with the current user). If you wish to get a user that you do
not have access to, consider using the REST implementation of
GetUser(UInt64)
Gets a generic user.
Declaration
public abstract SocketUser GetUser(ulong id)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id | The user snowflake ID. |
Returns
Type | Description |
---|---|
SocketUser | A generic WebSocket-based user; null when the user cannot be found. |
Remarks
This method gets the user present in the WebSocket cache with the given condition.
warning
Sometimes a user may return null due to Discord not sending offline users in large guilds (i.e. guild with 100+ members) actively. To download users on startup and to see more information about this subject, see AlwaysDownloadUsers.
note
This method does not attempt to fetch users that the logged-in user does not have access to (i.e.
users who don't share mutual guild(s) with the current user). If you wish to get a user that you do
not have access to, consider using the REST implementation of
GetVoiceRegionAsync(String, RequestOptions)
Gets a voice region.
Declaration
public abstract ValueTask<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
String | id | The identifier of the voice region (e.g. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
ValueTask<RestVoiceRegion> | A task that contains a REST-based voice region associated with the identifier; null if the voice region is not found. |
GetVoiceRegionsAsync(RequestOptions)
Gets all voice regions.
Declaration
public abstract ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
ValueTask<IReadOnlyCollection<RestVoiceRegion>> | A task that contains a read-only collection of REST-based voice regions. |
SetActivityAsync(IActivity)
Sets the activity
of the logged-in user.
Declaration
public abstract Task SetActivityAsync(IActivity activity)
Parameters
Type | Name | Description |
---|---|---|
IActivity | activity | The activity to be set. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous set operation. |
Remarks
This method sets the activity
of the user.
note
Discord will only accept setting of name and the type of activity.
warning
Bot accounts cannot set CustomStatus as their activity type and it will have no effect.
warning
Rich Presence cannot be set via this method or client. Rich Presence is strictly limited to RPC clients only.
SetCustomStatusAsync(String)
Sets the custom status of the logged-in user.
Declaration
public abstract Task SetCustomStatusAsync(string status)
Parameters
Type | Name | Description |
---|---|---|
String | status | The string that will be displayed as status. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous set operation. |
SetGameAsync(String, String, ActivityType)
Sets the game of the user.
Declaration
public abstract Task SetGameAsync(string name, string streamUrl = null, ActivityType type = default(ActivityType))
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the game. |
String | streamUrl | If streaming, the URL of the stream. Must be a valid Twitch URL. |
ActivityType | type | The type of the game. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous set operation. |
Remarks
warning
Bot accounts cannot set CustomStatus as their activity type and it will have no effect.
SetStatusAsync(UserStatus)
Sets the current status of the user (e.g. Online, Do not Disturb).
Declaration
public abstract Task SetStatusAsync(UserStatus status)
Parameters
Type | Name | Description |
---|---|---|
UserStatus | status | The new status to be set. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous set operation. |
StartAsync()
Declaration
public abstract Task StartAsync()
Returns
Type | Description |
---|---|
Task |
StopAsync()
Declaration
public abstract Task StopAsync()
Returns
Type | Description |
---|---|
Task |
Events
| Improve this Doc View SourceApplicationCommandCreated
Fired when a guild application command is created.
Declaration
public event Func<SocketApplicationCommand, Task> ApplicationCommandCreated
Event Type
Type | Description |
---|---|
Func<SocketApplicationCommand, Task> |
Remarks
This event is fired when an application command is created. The event handler must return a
The command that was deleted will be passed into the SocketApplicationCommand parameter.
note
This event is an undocumented discord event and may break at any time, its not recommended to rely on this event
ApplicationCommandDeleted
Fired when a guild application command is deleted.
Declaration
public event Func<SocketApplicationCommand, Task> ApplicationCommandDeleted
Event Type
Type | Description |
---|---|
Func<SocketApplicationCommand, Task> |
Remarks
This event is fired when an application command is deleted. The event handler must return a
The command that was deleted will be passed into the SocketApplicationCommand parameter.
note
This event is an undocumented discord event and may break at any time, its not recommended to rely on this event
ApplicationCommandUpdated
Fired when a guild application command is updated.
Declaration
public event Func<SocketApplicationCommand, Task> ApplicationCommandUpdated
Event Type
Type | Description |
---|---|
Func<SocketApplicationCommand, Task> |
Remarks
This event is fired when an application command is updated. The event handler must return a
The command that was deleted will be passed into the SocketApplicationCommand parameter.
note
This event is an undocumented discord event and may break at any time, its not recommended to rely on this event
AuditLogCreated
Fired when a guild audit log entry is created.
Declaration
public event Func<SocketAuditLogEntry, SocketGuild, Task> AuditLogCreated
Event Type
Type | Description |
---|---|
Func<SocketAuditLogEntry, SocketGuild, Task> |
AutocompleteExecuted
Fired when an autocomplete is used and its interaction is received.
Declaration
public event Func<SocketAutocompleteInteraction, Task> AutocompleteExecuted
Event Type
Type | Description |
---|---|
Func<SocketAutocompleteInteraction, Task> |
AutoModActionExecuted
Fired when an auto moderation rule is triggered by a user.
Declaration
public event Func<SocketGuild, AutoModRuleAction, AutoModActionExecutedData, Task> AutoModActionExecuted
Event Type
Type | Description |
---|---|
Func<SocketGuild, AutoModRuleAction, AutoModActionExecutedData, Task> |
AutoModRuleCreated
Fired when an auto moderation rule is created.
Declaration
public event Func<SocketAutoModRule, Task> AutoModRuleCreated
Event Type
Type | Description |
---|---|
Func<SocketAutoModRule, Task> |
AutoModRuleDeleted
Fired when an auto moderation rule is deleted.
Declaration
public event Func<SocketAutoModRule, Task> AutoModRuleDeleted
Event Type
Type | Description |
---|---|
Func<SocketAutoModRule, Task> |
AutoModRuleUpdated
Fired when an auto moderation rule is modified.
Declaration
public event Func<Cacheable<SocketAutoModRule, ulong>, SocketAutoModRule, Task> AutoModRuleUpdated
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketAutoModRule, UInt64>, SocketAutoModRule, Task> |
ButtonExecuted
Fired when a button is clicked and its interaction is received.
Declaration
public event Func<SocketMessageComponent, Task> ButtonExecuted
Event Type
Type | Description |
---|---|
Func<SocketMessageComponent, Task> |
ChannelCreated
Fired when a channel is created.
Declaration
public event Func<SocketChannel, Task> ChannelCreated
Event Type
Type | Description |
---|---|
Func<SocketChannel, Task> |
Remarks
This event is fired when a generic channel has been created. The event handler must return a
The newly created channel is passed into the event handler parameter. The given channel type may include, but not limited to, Private Channels (DM, Group), Guild Channels (Text, Voice, Category); see the derived classes of SocketChannel for more details.
Examples
|
Improve this Doc
View Source
ChannelDestroyed
Fired when a channel is destroyed.
Declaration
public event Func<SocketChannel, Task> ChannelDestroyed
Event Type
Type | Description |
---|---|
Func<SocketChannel, Task> |
Remarks
This event is fired when a generic channel has been destroyed. The event handler must return a
The destroyed channel is passed into the event handler parameter. The given channel type may include, but not limited to, Private Channels (DM, Group), Guild Channels (Text, Voice, Category); see the derived classes of SocketChannel for more details.
Examples
|
Improve this Doc
View Source
ChannelUpdated
Fired when a channel is updated.
Declaration
public event Func<SocketChannel, SocketChannel, Task> ChannelUpdated
Event Type
Type | Description |
---|---|
Func<SocketChannel, SocketChannel, Task> |
Remarks
This event is fired when a generic channel has been updated. The event handler must return a
The original (prior to update) channel is passed into the first SocketChannel, while the updated channel is passed into the second. The given channel type may include, but not limited to, Private Channels (DM, Group), Guild Channels (Text, Voice, Category); see the derived classes of SocketChannel for more details.
Examples
|
Improve this Doc
View Source
CurrentUserUpdated
Fired when the connected account is updated.
Declaration
public event Func<SocketSelfUser, SocketSelfUser, Task> CurrentUserUpdated
Event Type
Type | Description |
---|---|
Func<SocketSelfUser, SocketSelfUser, Task> |
GuildAvailable
Fired when a guild becomes available.
Declaration
public event Func<SocketGuild, Task> GuildAvailable
Event Type
Type | Description |
---|---|
Func<SocketGuild, Task> |
GuildJoinRequestDeleted
Fired when a user leaves without agreeing to the member screening
Declaration
public event Func<Cacheable<SocketGuildUser, ulong>, SocketGuild, Task> GuildJoinRequestDeleted
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketGuildUser, UInt64>, SocketGuild, Task> |
GuildMembersDownloaded
Fired when offline guild members are downloaded.
Declaration
public event Func<SocketGuild, Task> GuildMembersDownloaded
Event Type
Type | Description |
---|---|
Func<SocketGuild, Task> |
GuildMemberUpdated
Fired when a guild member is updated.
Declaration
public event Func<Cacheable<SocketGuildUser, ulong>, SocketGuildUser, Task> GuildMemberUpdated
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketGuildUser, UInt64>, SocketGuildUser, Task> |
GuildScheduledEventCancelled
Fired when a guild event is cancelled.
Declaration
public event Func<SocketGuildEvent, Task> GuildScheduledEventCancelled
Event Type
Type | Description |
---|---|
Func<SocketGuildEvent, Task> |
GuildScheduledEventCompleted
Fired when a guild event is completed.
Declaration
public event Func<SocketGuildEvent, Task> GuildScheduledEventCompleted
Event Type
Type | Description |
---|---|
Func<SocketGuildEvent, Task> |
GuildScheduledEventCreated
Fired when a guild event is created.
Declaration
public event Func<SocketGuildEvent, Task> GuildScheduledEventCreated
Event Type
Type | Description |
---|---|
Func<SocketGuildEvent, Task> |
GuildScheduledEventStarted
Fired when a guild event is started.
Declaration
public event Func<SocketGuildEvent, Task> GuildScheduledEventStarted
Event Type
Type | Description |
---|---|
Func<SocketGuildEvent, Task> |
GuildScheduledEventUpdated
Fired when a guild event is updated.
Declaration
public event Func<Cacheable<SocketGuildEvent, ulong>, SocketGuildEvent, Task> GuildScheduledEventUpdated
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketGuildEvent, UInt64>, SocketGuildEvent, Task> |
GuildScheduledEventUserAdd
Declaration
public event Func<Cacheable<SocketUser, RestUser, IUser, ulong>, SocketGuildEvent, Task> GuildScheduledEventUserAdd
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketUser, RestUser, IUser, UInt64>, SocketGuildEvent, Task> |
GuildScheduledEventUserRemove
Declaration
public event Func<Cacheable<SocketUser, RestUser, IUser, ulong>, SocketGuildEvent, Task> GuildScheduledEventUserRemove
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketUser, RestUser, IUser, UInt64>, SocketGuildEvent, Task> |
GuildStickerCreated
Fired when a sticker in a guild is created.
Declaration
public event Func<SocketCustomSticker, Task> GuildStickerCreated
Event Type
Type | Description |
---|---|
Func<SocketCustomSticker, Task> |
GuildStickerDeleted
Fired when a sticker in a guild is deleted.
Declaration
public event Func<SocketCustomSticker, Task> GuildStickerDeleted
Event Type
Type | Description |
---|---|
Func<SocketCustomSticker, Task> |
GuildStickerUpdated
Fired when a sticker in a guild is updated.
Declaration
public event Func<SocketCustomSticker, SocketCustomSticker, Task> GuildStickerUpdated
Event Type
Type | Description |
---|---|
Func<SocketCustomSticker, SocketCustomSticker, Task> |
GuildUnavailable
Fired when a guild becomes unavailable.
Declaration
public event Func<SocketGuild, Task> GuildUnavailable
Event Type
Type | Description |
---|---|
Func<SocketGuild, Task> |
GuildUpdated
Fired when a guild is updated.
Declaration
public event Func<SocketGuild, SocketGuild, Task> GuildUpdated
Event Type
Type | Description |
---|---|
Func<SocketGuild, SocketGuild, Task> |
IntegrationCreated
Fired when an integration is created.
Declaration
public event Func<IIntegration, Task> IntegrationCreated
Event Type
Type | Description |
---|---|
Func<IIntegration, Task> |
IntegrationDeleted
Fired when an integration is deleted.
Declaration
public event Func<IGuild, ulong, Optional<ulong>, Task> IntegrationDeleted
Event Type
Type | Description |
---|---|
Func<IGuild, UInt64, Optional<UInt64>, Task> |
IntegrationUpdated
Fired when an integration is updated.
Declaration
public event Func<IIntegration, Task> IntegrationUpdated
Event Type
Type | Description |
---|---|
Func<IIntegration, Task> |
InteractionCreated
Fired when an Interaction is created. This event covers all types of interactions including but not limited to: buttons, select menus, slash commands, autocompletes.
Declaration
public event Func<SocketInteraction, Task> InteractionCreated
Event Type
Type | Description |
---|---|
Func<SocketInteraction, Task> |
Remarks
This event is fired when an interaction is created. The event handler must return a
The interaction created will be passed into the SocketInteraction parameter.
InviteCreated
Fired when an invite is created.
Declaration
public event Func<SocketInvite, Task> InviteCreated
Event Type
Type | Description |
---|---|
Func<SocketInvite, Task> |
Remarks
This event is fired when an invite is created. The event handler must return a
The invite created will be passed into the SocketInvite parameter.
InviteDeleted
Fired when an invite is deleted.
Declaration
public event Func<SocketGuildChannel, string, Task> InviteDeleted
Event Type
Type | Description |
---|---|
Func<SocketGuildChannel, String, Task> |
Remarks
This event is fired when an invite is deleted. The event handler must return
a
The channel where this invite was created will be passed into the SocketGuildChannel parameter.
The code of the deleted invite will be passed into the
JoinedGuild
Fired when the connected account joins a guild.
Declaration
public event Func<SocketGuild, Task> JoinedGuild
Event Type
Type | Description |
---|---|
Func<SocketGuild, Task> |
LeftGuild
Fired when the connected account leaves a guild.
Declaration
public event Func<SocketGuild, Task> LeftGuild
Event Type
Type | Description |
---|---|
Func<SocketGuild, Task> |
MessageCommandExecuted
Fired when a message command is used and its interaction is received.
Declaration
public event Func<SocketMessageCommand, Task> MessageCommandExecuted
Event Type
Type | Description |
---|---|
Func<SocketMessageCommand, Task> |
MessageDeleted
Fired when a message is deleted.
Declaration
public event Func<Cacheable<IMessage, ulong>, Cacheable<IMessageChannel, ulong>, Task> MessageDeleted
Event Type
Type | Description |
---|---|
Func<Cacheable<IMessage, UInt64>, Cacheable<IMessageChannel, UInt64>, Task> |
Remarks
This event is fired when a message is deleted. The event handler must return a
important
It is not possible to retrieve the message via DownloadAsync(); the message cannot be retrieved by Discord after the message has been deleted.
The source channel of the removed message will be passed into the ISocketMessageChannel parameter.
Examples
|
Improve this Doc
View Source
MessageReceived
Fired when a message is received.
Declaration
public event Func<SocketMessage, Task> MessageReceived
Event Type
Type | Description |
---|---|
Func<SocketMessage, Task> |
Remarks
This event is fired when a message is received. The event handler must return a
The message that is sent to the client is passed into the event handler parameter as SocketMessage. This message may be a system message (i.e. SocketSystemMessage) or a user message (i.e. SocketUserMessage. See the derived classes of SocketMessage for more details.
Examples
The example below checks if the newly received message contains the target user.
|
Improve this Doc
View Source
MessagesBulkDeleted
Fired when multiple messages are bulk deleted.
Declaration
public event Func<IReadOnlyCollection<Cacheable<IMessage, ulong>>, Cacheable<IMessageChannel, ulong>, Task> MessagesBulkDeleted
Event Type
Type | Description |
---|---|
Func<IReadOnlyCollection<Cacheable<IMessage, UInt64>>, Cacheable<IMessageChannel, UInt64>, Task> |
Remarks
note
The MessageDeleted event will not be fired for individual messages contained in this event.
This event is fired when multiple messages are bulk deleted. The event handler must return a
important
It is not possible to retrieve the message via DownloadAsync(); the message cannot be retrieved by Discord after the message has been deleted.
The source channel of the removed message will be passed into the ISocketMessageChannel parameter.
MessageUpdated
Fired when a message is updated.
Declaration
public event Func<Cacheable<IMessage, ulong>, SocketMessage, ISocketMessageChannel, Task> MessageUpdated
Event Type
Type | Description |
---|---|
Func<Cacheable<IMessage, UInt64>, SocketMessage, ISocketMessageChannel, Task> |
Remarks
This event is fired when a message is updated. The event handler must return a
If caching is enabled via DiscordSocketConfig, the
Cacheable<TEntity, TId> entity will contain the original message; otherwise, in event
that the message cannot be retrieved, the snowflake ID of the message is preserved in the
The updated message will be passed into the SocketMessage parameter.
The source channel of the updated message will be passed into the ISocketMessageChannel parameter.
ModalSubmitted
Fired when a modal is submitted.
Declaration
public event Func<SocketModal, Task> ModalSubmitted
Event Type
Type | Description |
---|---|
Func<SocketModal, Task> |
PresenceUpdated
Fired when a users presence is updated.
Declaration
public event Func<SocketUser, SocketPresence, SocketPresence, Task> PresenceUpdated
Event Type
Type | Description |
---|---|
Func<SocketUser, SocketPresence, SocketPresence, Task> |
ReactionAdded
Fired when a reaction is added to a message.
Declaration
public event Func<Cacheable<IUserMessage, ulong>, Cacheable<IMessageChannel, ulong>, SocketReaction, Task> ReactionAdded
Event Type
Type | Description |
---|---|
Func<Cacheable<IUserMessage, UInt64>, Cacheable<IMessageChannel, UInt64>, SocketReaction, Task> |
Remarks
This event is fired when a reaction is added to a user message. The event handler must return a
If caching is enabled via DiscordSocketConfig, the
Cacheable<TEntity, TId> entity will contain the original message; otherwise, in event
that the message cannot be retrieved, the snowflake ID of the message is preserved in the
The source channel of the reaction addition will be passed into the ISocketMessageChannel parameter.
The reaction that was added will be passed into the SocketReaction parameter.
note
When fetching the reaction from this event, a user may not be provided under User. Please see the documentation of the property for more information.
Examples
|
Improve this Doc
View Source
ReactionRemoved
Fired when a reaction is removed from a message.
Declaration
public event Func<Cacheable<IUserMessage, ulong>, Cacheable<IMessageChannel, ulong>, SocketReaction, Task> ReactionRemoved
Event Type
Type | Description |
---|---|
Func<Cacheable<IUserMessage, UInt64>, Cacheable<IMessageChannel, UInt64>, SocketReaction, Task> |
ReactionsCleared
Fired when all reactions to a message are cleared.
Declaration
public event Func<Cacheable<IUserMessage, ulong>, Cacheable<IMessageChannel, ulong>, Task> ReactionsCleared
Event Type
Type | Description |
---|---|
Func<Cacheable<IUserMessage, UInt64>, Cacheable<IMessageChannel, UInt64>, Task> |
ReactionsRemovedForEmote
Fired when all reactions to a message with a specific emote are removed.
Declaration
public event Func<Cacheable<IUserMessage, ulong>, Cacheable<IMessageChannel, ulong>, IEmote, Task> ReactionsRemovedForEmote
Event Type
Type | Description |
---|---|
Func<Cacheable<IUserMessage, UInt64>, Cacheable<IMessageChannel, UInt64>, IEmote, Task> |
Remarks
This event is fired when all reactions to a message with a specific emote are removed.
The event handler must return a
The channel where this message was sent will be passed into the ISocketMessageChannel parameter.
The emoji that all reactions had and were removed will be passed into the IEmote parameter.
RecipientAdded
Fired when a user joins a group channel.
Declaration
public event Func<SocketGroupUser, Task> RecipientAdded
Event Type
Type | Description |
---|---|
Func<SocketGroupUser, Task> |
RecipientRemoved
Fired when a user is removed from a group channel.
Declaration
public event Func<SocketGroupUser, Task> RecipientRemoved
Event Type
Type | Description |
---|---|
Func<SocketGroupUser, Task> |
RequestToSpeak
Fired when a user requests to speak within a stage channel.
Declaration
public event Func<SocketStageChannel, SocketGuildUser, Task> RequestToSpeak
Event Type
Type | Description |
---|---|
Func<SocketStageChannel, SocketGuildUser, Task> |
RoleCreated
Fired when a role is created.
Declaration
public event Func<SocketRole, Task> RoleCreated
Event Type
Type | Description |
---|---|
Func<SocketRole, Task> |
RoleDeleted
Fired when a role is deleted.
Declaration
public event Func<SocketRole, Task> RoleDeleted
Event Type
Type | Description |
---|---|
Func<SocketRole, Task> |
RoleUpdated
Fired when a role is updated.
Declaration
public event Func<SocketRole, SocketRole, Task> RoleUpdated
Event Type
Type | Description |
---|---|
Func<SocketRole, SocketRole, Task> |
SelectMenuExecuted
Fired when a select menu is used and its interaction is received.
Declaration
public event Func<SocketMessageComponent, Task> SelectMenuExecuted
Event Type
Type | Description |
---|---|
Func<SocketMessageComponent, Task> |
SlashCommandExecuted
Fired when a slash command is used and its interaction is received.
Declaration
public event Func<SocketSlashCommand, Task> SlashCommandExecuted
Event Type
Type | Description |
---|---|
Func<SocketSlashCommand, Task> |
SpeakerAdded
Fired when a speaker is added in a stage channel.
Declaration
public event Func<SocketStageChannel, SocketGuildUser, Task> SpeakerAdded
Event Type
Type | Description |
---|---|
Func<SocketStageChannel, SocketGuildUser, Task> |
SpeakerRemoved
Fired when a speaker is removed from a stage channel.
Declaration
public event Func<SocketStageChannel, SocketGuildUser, Task> SpeakerRemoved
Event Type
Type | Description |
---|---|
Func<SocketStageChannel, SocketGuildUser, Task> |
StageEnded
Fired when a stage ends.
Declaration
public event Func<SocketStageChannel, Task> StageEnded
Event Type
Type | Description |
---|---|
Func<SocketStageChannel, Task> |
StageStarted
Fired when a stage is started.
Declaration
public event Func<SocketStageChannel, Task> StageStarted
Event Type
Type | Description |
---|---|
Func<SocketStageChannel, Task> |
StageUpdated
Fired when a stage is updated.
Declaration
public event Func<SocketStageChannel, SocketStageChannel, Task> StageUpdated
Event Type
Type | Description |
---|---|
Func<SocketStageChannel, SocketStageChannel, Task> |
ThreadCreated
Fired when a thread is created within a guild, or when the current user is added to a thread.
Declaration
public event Func<SocketThreadChannel, Task> ThreadCreated
Event Type
Type | Description |
---|---|
Func<SocketThreadChannel, Task> |
ThreadDeleted
Fired when a thread is deleted.
Declaration
public event Func<Cacheable<SocketThreadChannel, ulong>, Task> ThreadDeleted
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketThreadChannel, UInt64>, Task> |
ThreadMemberJoined
Fired when a user joins a thread
Declaration
public event Func<SocketThreadUser, Task> ThreadMemberJoined
Event Type
Type | Description |
---|---|
Func<SocketThreadUser, Task> |
ThreadMemberLeft
Fired when a user leaves a thread
Declaration
public event Func<SocketThreadUser, Task> ThreadMemberLeft
Event Type
Type | Description |
---|---|
Func<SocketThreadUser, Task> |
ThreadUpdated
Fired when a thread is updated within a guild.
Declaration
public event Func<Cacheable<SocketThreadChannel, ulong>, SocketThreadChannel, Task> ThreadUpdated
Event Type
Type | Description |
---|---|
Func<Cacheable<SocketThreadChannel, UInt64>, SocketThreadChannel, Task> |
UserBanned
Fired when a user is banned from a guild.
Declaration
public event Func<SocketUser, SocketGuild, Task> UserBanned
Event Type
Type | Description |
---|---|
Func<SocketUser, SocketGuild, Task> |
UserCommandExecuted
Fired when a user command is used and its interaction is received.
Declaration
public event Func<SocketUserCommand, Task> UserCommandExecuted
Event Type
Type | Description |
---|---|
Func<SocketUserCommand, Task> |
UserIsTyping
Fired when a user starts typing.
Declaration
public event Func<Cacheable<IUser, ulong>, Cacheable<IMessageChannel, ulong>, Task> UserIsTyping
Event Type
Type | Description |
---|---|
Func<Cacheable<IUser, UInt64>, Cacheable<IMessageChannel, UInt64>, Task> |
UserJoined
Fired when a user joins a guild.
Declaration
public event Func<SocketGuildUser, Task> UserJoined
Event Type
Type | Description |
---|---|
Func<SocketGuildUser, Task> |
UserLeft
Fired when a user leaves a guild.
Declaration
public event Func<SocketGuild, SocketUser, Task> UserLeft
Event Type
Type | Description |
---|---|
Func<SocketGuild, SocketUser, Task> |
UserUnbanned
Fired when a user is unbanned from a guild.
Declaration
public event Func<SocketUser, SocketGuild, Task> UserUnbanned
Event Type
Type | Description |
---|---|
Func<SocketUser, SocketGuild, Task> |
UserUpdated
Fired when a user is updated.
Declaration
public event Func<SocketUser, SocketUser, Task> UserUpdated
Event Type
Type | Description |
---|---|
Func<SocketUser, SocketUser, Task> |
UserVoiceStateUpdated
Fired when a user joins, leaves, or moves voice channels.
Declaration
public event Func<SocketUser, SocketVoiceState, SocketVoiceState, Task> UserVoiceStateUpdated
Event Type
Type | Description |
---|---|
Func<SocketUser, SocketVoiceState, SocketVoiceState, Task> |
VoiceServerUpdated
Fired when the bot connects to a Discord voice server.
Declaration
public event Func<SocketVoiceServer, Task> VoiceServerUpdated
Event Type
Type | Description |
---|---|
Func<SocketVoiceServer, Task> |
WebhooksUpdated
Fired when a webhook is modified, moved, or deleted. If the webhook was moved the channel represents the destination channel, not the source.
Declaration
public event Func<SocketGuild, SocketChannel, Task> WebhooksUpdated
Event Type
Type | Description |
---|---|
Func<SocketGuild, SocketChannel, Task> |