Search Results for

    Show / Hide Table of Contents

    Class BaseSocketClient

    Represents the base of a WebSocket-based Discord client.

    Inheritance
    Object
    BaseDiscordClient
    BaseSocketClient
    DiscordShardedClient
    DiscordSocketClient
    Implements
    IDiscordClient
    IDisposable
    IAsyncDisposable
    Inherited Members
    BaseDiscordClient.Log
    BaseDiscordClient.LoggedIn
    BaseDiscordClient.LoggedOut
    BaseDiscordClient.LoginState
    BaseDiscordClient.TokenType
    BaseDiscordClient.LoginAsync(TokenType, String, Boolean)
    BaseDiscordClient.LogoutAsync()
    BaseDiscordClient.Dispose()
    BaseDiscordClient.DisposeAsync()
    BaseDiscordClient.GetRecommendedShardCountAsync(RequestOptions)
    BaseDiscordClient.GetBotGatewayAsync(RequestOptions)
    BaseDiscordClient.IDiscordClient.ConnectionState
    BaseDiscordClient.IDiscordClient.CurrentUser
    Namespace: Discord.WebSocket
    Assembly: Discord.Net.WebSocket.dll
    Syntax
    public abstract class BaseSocketClient : BaseDiscordClient, IDiscordClient, IDisposable, IAsyncDisposable

    Fields

    | Improve this Doc View Source

    BaseConfig

    Declaration
    protected readonly DiscordSocketConfig BaseConfig
    Field Value
    Type Description
    DiscordSocketConfig

    Properties

    | Improve this Doc View Source

    Activity

    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.

    | Improve this Doc View Source

    CurrentUser

    Gets the current logged-in user.

    Declaration
    public virtual SocketSelfUser CurrentUser { get; protected set; }
    Property Value
    Type Description
    SocketSelfUser
    | Improve this Doc View Source

    DefaultStickerPacks

    Gets a collection of default stickers.

    Declaration
    public abstract IReadOnlyCollection<StickerPack<SocketSticker>> DefaultStickerPacks { get; }
    Property Value
    Type Description
    IReadOnlyCollection<StickerPack<SocketSticker>>
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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 that represents the round-trip latency to the WebSocket server. Please note that this value does not represent a "true" latency for operations such as sending a message.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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 Source

    CreateGuildAsync(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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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. 381889909113225237).

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    GetInviteAsync(String, RequestOptions)

    Gets an invite.

    Declaration
    public Task<RestInviteMetadata> GetInviteAsync(string inviteId, RequestOptions options = null)
    Parameters
    Type Name Description
    String inviteId

    The invitation identifier.

    RequestOptions options

    The options to be used when sending the request.

    Returns
    Type Description
    Task<RestInviteMetadata>

    A task that represents the asynchronous get operation. The task result contains the invite information.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    GetUser(String, String)

    Gets a user.

    Declaration
    public abstract SocketUser GetUser(string username, string discriminator)
    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 .

    | Improve this Doc View Source

    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 .

    | Improve this Doc View Source

    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. eu-central ).

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    StartAsync()

    Declaration
    public abstract Task StartAsync()
    Returns
    Type Description
    Task
    | Improve this Doc View Source

    StopAsync()

    Declaration
    public abstract Task StopAsync()
    Returns
    Type Description
    Task

    Events

    | Improve this Doc View Source

    ApplicationCommandCreated

    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 and accept a SocketApplicationCommand as its parameter.

    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

    | Improve this Doc View Source

    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 and accept a SocketApplicationCommand as its parameter.

    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

    | Improve this Doc View Source

    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 and accept a SocketApplicationCommand as its parameter.

    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

    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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 and accept a SocketChannel as its parameter.

    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 and accept a SocketChannel as its parameter.

    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 and accept 2 SocketChannel as its parameters.

    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>
    | Improve this Doc View Source

    GuildAvailable

    Fired when a guild becomes available.

    Declaration
    public event Func<SocketGuild, Task> GuildAvailable
    Event Type
    Type Description
    Func<SocketGuild, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    GuildMembersDownloaded

    Fired when offline guild members are downloaded.

    Declaration
    public event Func<SocketGuild, Task> GuildMembersDownloaded
    Event Type
    Type Description
    Func<SocketGuild, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    GuildScheduledEventCancelled

    Fired when a guild event is cancelled.

    Declaration
    public event Func<SocketGuildEvent, Task> GuildScheduledEventCancelled
    Event Type
    Type Description
    Func<SocketGuildEvent, Task>
    | Improve this Doc View Source

    GuildScheduledEventCompleted

    Fired when a guild event is completed.

    Declaration
    public event Func<SocketGuildEvent, Task> GuildScheduledEventCompleted
    Event Type
    Type Description
    Func<SocketGuildEvent, Task>
    | Improve this Doc View Source

    GuildScheduledEventCreated

    Fired when a guild event is created.

    Declaration
    public event Func<SocketGuildEvent, Task> GuildScheduledEventCreated
    Event Type
    Type Description
    Func<SocketGuildEvent, Task>
    | Improve this Doc View Source

    GuildScheduledEventStarted

    Fired when a guild event is started.

    Declaration
    public event Func<SocketGuildEvent, Task> GuildScheduledEventStarted
    Event Type
    Type Description
    Func<SocketGuildEvent, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    GuildStickerCreated

    Fired when a sticker in a guild is created.

    Declaration
    public event Func<SocketCustomSticker, Task> GuildStickerCreated
    Event Type
    Type Description
    Func<SocketCustomSticker, Task>
    | Improve this Doc View Source

    GuildStickerDeleted

    Fired when a sticker in a guild is deleted.

    Declaration
    public event Func<SocketCustomSticker, Task> GuildStickerDeleted
    Event Type
    Type Description
    Func<SocketCustomSticker, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    GuildUnavailable

    Fired when a guild becomes unavailable.

    Declaration
    public event Func<SocketGuild, Task> GuildUnavailable
    Event Type
    Type Description
    Func<SocketGuild, Task>
    | Improve this Doc View Source

    GuildUpdated

    Fired when a guild is updated.

    Declaration
    public event Func<SocketGuild, SocketGuild, Task> GuildUpdated
    Event Type
    Type Description
    Func<SocketGuild, SocketGuild, Task>
    | Improve this Doc View Source

    IntegrationCreated

    Fired when an integration is created.

    Declaration
    public event Func<IIntegration, Task> IntegrationCreated
    Event Type
    Type Description
    Func<IIntegration, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    IntegrationUpdated

    Fired when an integration is updated.

    Declaration
    public event Func<IIntegration, Task> IntegrationUpdated
    Event Type
    Type Description
    Func<IIntegration, Task>
    | Improve this Doc View Source

    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 and accept a SocketInteraction as its parameter.

    The interaction created will be passed into the SocketInteraction parameter.

    | Improve this Doc View Source

    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 and accept a SocketInvite as its parameter.

    The invite created will be passed into the SocketInvite parameter.

    | Improve this Doc View Source

    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 and accept a SocketGuildChannel and as its parameter.

    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 parameter.

    | Improve this Doc View Source

    JoinedGuild

    Fired when the connected account joins a guild.

    Declaration
    public event Func<SocketGuild, Task> JoinedGuild
    Event Type
    Type Description
    Func<SocketGuild, Task>
    | Improve this Doc View Source

    LeftGuild

    Fired when the connected account leaves a guild.

    Declaration
    public event Func<SocketGuild, Task> LeftGuild
    Event Type
    Type Description
    Func<SocketGuild, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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 and accept a Cacheable<TEntity, TId> and ISocketMessageChannel as its parameters.

    important

    It is not possible to retrieve the message via DownloadAsync(); the message cannot be retrieved by Discord after the message has been deleted.

    If caching is enabled via DiscordSocketConfig, the Cacheable<TEntity, TId> entity will contain the deleted 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 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 and accept a SocketMessage as its parameter.

    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 and accept an and ISocketMessageChannel as its parameters.

    important

    It is not possible to retrieve the message via DownloadAsync(); the message cannot be retrieved by Discord after the message has been deleted.

    If caching is enabled via DiscordSocketConfig, the Cacheable<TEntity, TId> entity will contain the deleted 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 removed message will be passed into the ISocketMessageChannel parameter.

    | Improve this Doc View Source

    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 and accept a Cacheable<TEntity, TId>, SocketMessage, and ISocketMessageChannel as its parameters.

    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.

    | Improve this Doc View Source

    ModalSubmitted

    Fired when a modal is submitted.

    Declaration
    public event Func<SocketModal, Task> ModalSubmitted
    Event Type
    Type Description
    Func<SocketModal, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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 and accept a Cacheable<TEntity, TId>, an ISocketMessageChannel, and a SocketReaction as its parameter.

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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 and accept a ISocketMessageChannel and a IEmote as its parameters.

    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.

    | Improve this Doc View Source

    RecipientAdded

    Fired when a user joins a group channel.

    Declaration
    public event Func<SocketGroupUser, Task> RecipientAdded
    Event Type
    Type Description
    Func<SocketGroupUser, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    RoleCreated

    Fired when a role is created.

    Declaration
    public event Func<SocketRole, Task> RoleCreated
    Event Type
    Type Description
    Func<SocketRole, Task>
    | Improve this Doc View Source

    RoleDeleted

    Fired when a role is deleted.

    Declaration
    public event Func<SocketRole, Task> RoleDeleted
    Event Type
    Type Description
    Func<SocketRole, Task>
    | Improve this Doc View Source

    RoleUpdated

    Fired when a role is updated.

    Declaration
    public event Func<SocketRole, SocketRole, Task> RoleUpdated
    Event Type
    Type Description
    Func<SocketRole, SocketRole, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    StageEnded

    Fired when a stage ends.

    Declaration
    public event Func<SocketStageChannel, Task> StageEnded
    Event Type
    Type Description
    Func<SocketStageChannel, Task>
    | Improve this Doc View Source

    StageStarted

    Fired when a stage is started.

    Declaration
    public event Func<SocketStageChannel, Task> StageStarted
    Event Type
    Type Description
    Func<SocketStageChannel, Task>
    | Improve this Doc View Source

    StageUpdated

    Fired when a stage is updated.

    Declaration
    public event Func<SocketStageChannel, SocketStageChannel, Task> StageUpdated
    Event Type
    Type Description
    Func<SocketStageChannel, SocketStageChannel, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    ThreadMemberJoined

    Fired when a user joins a thread

    Declaration
    public event Func<SocketThreadUser, Task> ThreadMemberJoined
    Event Type
    Type Description
    Func<SocketThreadUser, Task>
    | Improve this Doc View Source

    ThreadMemberLeft

    Fired when a user leaves a thread

    Declaration
    public event Func<SocketThreadUser, Task> ThreadMemberLeft
    Event Type
    Type Description
    Func<SocketThreadUser, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    UserJoined

    Fired when a user joins a guild.

    Declaration
    public event Func<SocketGuildUser, Task> UserJoined
    Event Type
    Type Description
    Func<SocketGuildUser, Task>
    | Improve this Doc View Source

    UserLeft

    Fired when a user leaves a guild.

    Declaration
    public event Func<SocketGuild, SocketUser, Task> UserLeft
    Event Type
    Type Description
    Func<SocketGuild, SocketUser, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    UserUpdated

    Fired when a user is updated.

    Declaration
    public event Func<SocketUser, SocketUser, Task> UserUpdated
    Event Type
    Type Description
    Func<SocketUser, SocketUser, Task>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>
    | Improve this Doc View Source

    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>

    Implements

    IDiscordClient
    IDisposable
    IAsyncDisposable

    Theme

    • Improve this Doc
    • View Source
    In This Article
    Back to top Discord.Net (c) 2015-2022 3.9.0