Class BaseSocketClient
Represents the base of a WebSocket-based Discord client.
Inheritance
Inherited Members
Namespace: Discord.WebSocket
Assembly: Discord.Net.WebSocket.dll
Syntax
public abstract class BaseSocketClient : BaseDiscordClient, IDiscordClient, IDisposable
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 SocketSelfUser CurrentUser { get; protected set; }
Property Value
| Type | Description |
|---|---|
| SocketSelfUser |
Guilds
Gets a collection of guilds that the user is currently in.
Declaration
public abstract IReadOnlyCollection<SocketGuild> Guilds { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.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 |
|---|---|
| System.Int32 | An System.Int32 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. |
PrivateChannels
Gets a collection of private channels opened in this session.
Declaration
public abstract IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.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. |
VoiceRegions
Gets a collection of available voice regions.
Declaration
public abstract IReadOnlyCollection<RestVoiceRegion> VoiceRegions { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyCollection<RestVoiceRegion> | A read-only collection of voice regions that the user has access to. |
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 |
|---|---|---|
| System.String | name | The name of the new guild. |
| IVoiceRegion | region | The voice region to create the guild with. |
| System.IO.Stream | jpegIcon | The icon of the guild. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.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 |
|---|---|---|
| System.Collections.Generic.IEnumerable<IGuild> | guilds | The guilds to download the members from. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.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 |
|---|---|
| System.Threading.Tasks.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 |
|---|---|---|
| System.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;
|
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 |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.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 |
|---|---|---|
| System.UInt64 | id | The guild snowflake identifier. |
Returns
| Type | Description |
|---|---|
| SocketGuild | A WebSocket-based guild associated with the snowflake identifier; |
GetInviteAsync(String, RequestOptions)
Gets an invite.
Declaration
public Task<RestInviteMetadata> GetInviteAsync(string inviteId, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | inviteId | The invitation identifier. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestInviteMetadata> | A task that represents the asynchronous get operation. The task result contains the invite information. |
GetUser(String, String)
Gets a user.
Declaration
public abstract SocketUser GetUser(string username, string discriminator)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | username | The name of the user. |
| System.String | discriminator | The discriminator value of the user. |
Returns
| Type | Description |
|---|---|
| SocketUser | A generic WebSocket-based user; |
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 GetUserAsync(UInt64, RequestOptions).
GetUser(UInt64)
Gets a generic user.
Declaration
public abstract SocketUser GetUser(ulong id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | The user snowflake ID. |
Returns
| Type | Description |
|---|---|
| SocketUser | A generic WebSocket-based user; |
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 GetUserAsync(UInt64, RequestOptions).
GetVoiceRegion(String)
Gets a voice region.
Declaration
public abstract RestVoiceRegion GetVoiceRegion(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | The identifier of the voice region (e.g. |
Returns
| Type | Description |
|---|---|
| RestVoiceRegion | A REST-based voice region associated with the identifier; |
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 |
|---|---|
| System.Threading.Tasks.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
Rich Presence cannot be set via this method or client. Rich Presence is strictly limited to RPC clients only.
SetGameAsync(String, String, ActivityType)
Sets the game of the user.
Declaration
public abstract Task SetGameAsync(string name, string streamUrl = null, ActivityType type = ActivityType.Playing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the game. |
| System.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 |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous set operation. |
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 |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous set operation. |
StartAsync()
Starts the connection between Discord and the client..
Declaration
public abstract Task StartAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous start operation. |
Remarks
This method will initialize the connection between the client and Discord.
important
This method will immediately return after it is called, as it will initialize the connection on another thread.
StopAsync()
Stops the connection between Discord and the client.
Declaration
public abstract Task StopAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous stop operation. |
Events
| Improve this Doc View SourceChannelCreated
Fired when a channel is created.
Declaration
public event Func<SocketChannel, Task> ChannelCreated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketChannel, System.Threading.Tasks.Task> |
Remarks
This event is fired when a generic channel has been created. The event handler must return a System.Threading.Tasks.Task 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
public void HookChannelCreated(BaseSocketClient client)
=> client.ChannelCreated += HandleChannelCreated;
public Task HandleChannelCreated(SocketChannel channel)
{
if (channel is SocketGuildChannel guildChannel)
Console.WriteLine($"A new channel '{guildChannel.Name}'({guildChannel.Id}, {guildChannel.GetType()})"
+ $"has been created at {guildChannel.CreatedAt}.");
return Task.CompletedTask;
}
|
Improve this Doc
View Source
ChannelDestroyed
Fired when a channel is destroyed.
Declaration
public event Func<SocketChannel, Task> ChannelDestroyed
Event Type
| Type | Description |
|---|---|
| System.Func<SocketChannel, System.Threading.Tasks.Task> |
Remarks
This event is fired when a generic channel has been destroyed. The event handler must return a System.Threading.Tasks.Task 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
public void HookChannelDestroyed(BaseSocketClient client)
=> client.ChannelDestroyed += HandleChannelDestroyed;
public Task HandleChannelDestroyed(SocketChannel channel)
{
if (channel is SocketGuildChannel guildChannel)
Console.WriteLine(
$"A new channel '{guildChannel.Name}'({guildChannel.Id}, {guildChannel.GetType()}) has been deleted.");
return Task.CompletedTask;
}
|
Improve this Doc
View Source
ChannelUpdated
Fired when a channel is updated.
Declaration
public event Func<SocketChannel, SocketChannel, Task> ChannelUpdated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketChannel, SocketChannel, System.Threading.Tasks.Task> |
Remarks
This event is fired when a generic channel has been destroyed. The event handler must return a System.Threading.Tasks.Task 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
public void HookChannelUpdated(BaseSocketClient client)
=> client.ChannelUpdated += HandleChannelRename;
public Task HandleChannelRename(SocketChannel beforeChannel, SocketChannel afterChannel)
{
if (beforeChannel is SocketGuildChannel beforeGuildChannel &&
afterChannel is SocketGuildChannel afterGuildChannel)
if (beforeGuildChannel.Name != afterGuildChannel.Name)
Console.WriteLine(
$"A channel ({beforeChannel.Id}) is renamed from {beforeGuildChannel.Name} to {afterGuildChannel.Name}.");
return Task.CompletedTask;
}
|
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 |
|---|---|
| System.Func<SocketSelfUser, SocketSelfUser, System.Threading.Tasks.Task> |
GuildAvailable
Fired when a guild becomes available.
Declaration
public event Func<SocketGuild, Task> GuildAvailable
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuild, System.Threading.Tasks.Task> |
GuildMembersDownloaded
Fired when offline guild members are downloaded.
Declaration
public event Func<SocketGuild, Task> GuildMembersDownloaded
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuild, System.Threading.Tasks.Task> |
GuildMemberUpdated
Fired when a guild member is updated, or a member presence is updated.
Declaration
public event Func<SocketGuildUser, SocketGuildUser, Task> GuildMemberUpdated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuildUser, SocketGuildUser, System.Threading.Tasks.Task> |
GuildUnavailable
Fired when a guild becomes unavailable.
Declaration
public event Func<SocketGuild, Task> GuildUnavailable
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuild, System.Threading.Tasks.Task> |
GuildUpdated
Fired when a guild is updated.
Declaration
public event Func<SocketGuild, SocketGuild, Task> GuildUpdated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuild, SocketGuild, System.Threading.Tasks.Task> |
JoinedGuild
Fired when the connected account joins a guild.
Declaration
public event Func<SocketGuild, Task> JoinedGuild
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuild, System.Threading.Tasks.Task> |
LeftGuild
Fired when the connected account leaves a guild.
Declaration
public event Func<SocketGuild, Task> LeftGuild
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuild, System.Threading.Tasks.Task> |
MessageDeleted
Fired when a message is deleted.
Declaration
public event Func<Cacheable<IMessage, ulong>, ISocketMessageChannel, Task> MessageDeleted
Event Type
| Type | Description |
|---|---|
| System.Func<Cacheable<IMessage, System.UInt64>, ISocketMessageChannel, System.Threading.Tasks.Task> |
Remarks
This event is fired when a message is deleted. The event handler must return a System.Threading.Tasks.Task 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.
The source channel of the removed message will be passed into the ISocketMessageChannel parameter.
Examples
public void HookMessageDeleted(BaseSocketClient client)
=> client.MessageDeleted += HandleMessageDelete;
public Task HandleMessageDelete(Cacheable<IMessage, ulong> cachedMessage, ISocketMessageChannel channel)
{
// check if the message exists in cache; if not, we cannot report what was removed
if (!cachedMessage.HasValue) return Task.CompletedTask;
var message = cachedMessage.Value;
Console.WriteLine(
$"A message ({message.Id}) from {message.Author} was removed from the channel {channel.Name} ({channel.Id}):"
+ Environment.NewLine
+ message.Content);
return Task.CompletedTask;
}
|
Improve this Doc
View Source
MessageReceived
Fired when a message is received.
Declaration
public event Func<SocketMessage, Task> MessageReceived
Event Type
| Type | Description |
|---|---|
| System.Func<SocketMessage, System.Threading.Tasks.Task> |
Remarks
This event is fired when a message is received. The event handler must return a System.Threading.Tasks.Task 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.
private readonly ulong[] _targetUserIds = {168693960628371456, 53905483156684800};
public void HookMessageReceived(BaseSocketClient client)
=> client.MessageReceived += HandleMessageReceived;
public Task HandleMessageReceived(SocketMessage message)
{
// check if the message is a user message as opposed to a system message (e.g. Clyde, pins, etc.)
if (!(message is SocketUserMessage userMessage)) return Task.CompletedTask;
// check if the message origin is a guild message channel
if (!(userMessage.Channel is SocketTextChannel textChannel)) return Task.CompletedTask;
// check if the target user was mentioned
var targetUsers = userMessage.MentionedUsers.Where(x => _targetUserIds.Contains(x.Id));
foreach (var targetUser in targetUsers)
Console.WriteLine(
$"{targetUser} was mentioned in the message '{message.Content}' by {message.Author} in {textChannel.Name}.");
return Task.CompletedTask;
}
| Improve this Doc View Source
MessagesBulkDeleted
Fired when multiple messages are bulk deleted.
Declaration
public event Func<IReadOnlyCollection<Cacheable<IMessage, ulong>>, ISocketMessageChannel, Task> MessagesBulkDeleted
Event Type
| Type | Description |
|---|---|
| System.Func<System.Collections.Generic.IReadOnlyCollection<Cacheable<IMessage, System.UInt64>>, ISocketMessageChannel, System.Threading.Tasks.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 System.Threading.Tasks.Task and accept an System.Collections.Generic.IReadOnlyCollection<T> 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.
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 |
|---|---|
| System.Func<Cacheable<IMessage, System.UInt64>, SocketMessage, ISocketMessageChannel, System.Threading.Tasks.Task> |
Remarks
This event is fired when a message is updated. The event handler must return a System.Threading.Tasks.Task 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 System.UInt64.
The updated message will be passed into the SocketMessage parameter.
The source channel of the updated message will be passed into the ISocketMessageChannel parameter.
ReactionAdded
Fired when a reaction is added to a message.
Declaration
public event Func<Cacheable<IUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task> ReactionAdded
Event Type
| Type | Description |
|---|---|
| System.Func<Cacheable<IUserMessage, System.UInt64>, ISocketMessageChannel, SocketReaction, System.Threading.Tasks.Task> |
Remarks
This event is fired when a reaction is added to a user message. The event handler must return a System.Threading.Tasks.Task 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 System.UInt64.
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
public void HookReactionAdded(BaseSocketClient client)
=> client.ReactionAdded += HandleReactionAddedAsync;
public async Task HandleReactionAddedAsync(Cacheable<IUserMessage, ulong> cachedMessage,
ISocketMessageChannel originChannel, SocketReaction reaction)
{
var message = await cachedMessage.GetOrDownloadAsync();
if (message != null && reaction.User.IsSpecified)
Console.WriteLine($"{reaction.User.Value} just added a reaction '{reaction.Emote}' " +
$"to {message.Author}'s message ({message.Id}).");
}
|
Improve this Doc
View Source
ReactionRemoved
Fired when a reaction is removed from a message.
Declaration
public event Func<Cacheable<IUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task> ReactionRemoved
Event Type
| Type | Description |
|---|---|
| System.Func<Cacheable<IUserMessage, System.UInt64>, ISocketMessageChannel, SocketReaction, System.Threading.Tasks.Task> |
ReactionsCleared
Fired when all reactions to a message are cleared.
Declaration
public event Func<Cacheable<IUserMessage, ulong>, ISocketMessageChannel, Task> ReactionsCleared
Event Type
| Type | Description |
|---|---|
| System.Func<Cacheable<IUserMessage, System.UInt64>, ISocketMessageChannel, System.Threading.Tasks.Task> |
RecipientAdded
Fired when a user joins a group channel.
Declaration
public event Func<SocketGroupUser, Task> RecipientAdded
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGroupUser, System.Threading.Tasks.Task> |
RecipientRemoved
Fired when a user is removed from a group channel.
Declaration
public event Func<SocketGroupUser, Task> RecipientRemoved
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGroupUser, System.Threading.Tasks.Task> |
RoleCreated
Fired when a role is created.
Declaration
public event Func<SocketRole, Task> RoleCreated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketRole, System.Threading.Tasks.Task> |
RoleDeleted
Fired when a role is deleted.
Declaration
public event Func<SocketRole, Task> RoleDeleted
Event Type
| Type | Description |
|---|---|
| System.Func<SocketRole, System.Threading.Tasks.Task> |
RoleUpdated
Fired when a role is updated.
Declaration
public event Func<SocketRole, SocketRole, Task> RoleUpdated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketRole, SocketRole, System.Threading.Tasks.Task> |
UserBanned
Fired when a user is banned from a guild.
Declaration
public event Func<SocketUser, SocketGuild, Task> UserBanned
Event Type
| Type | Description |
|---|---|
| System.Func<SocketUser, SocketGuild, System.Threading.Tasks.Task> |
UserIsTyping
Fired when a user starts typing.
Declaration
public event Func<SocketUser, ISocketMessageChannel, Task> UserIsTyping
Event Type
| Type | Description |
|---|---|
| System.Func<SocketUser, ISocketMessageChannel, System.Threading.Tasks.Task> |
UserJoined
Fired when a user joins a guild.
Declaration
public event Func<SocketGuildUser, Task> UserJoined
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuildUser, System.Threading.Tasks.Task> |
UserLeft
Fired when a user leaves a guild.
Declaration
public event Func<SocketGuildUser, Task> UserLeft
Event Type
| Type | Description |
|---|---|
| System.Func<SocketGuildUser, System.Threading.Tasks.Task> |
UserUnbanned
Fired when a user is unbanned from a guild.
Declaration
public event Func<SocketUser, SocketGuild, Task> UserUnbanned
Event Type
| Type | Description |
|---|---|
| System.Func<SocketUser, SocketGuild, System.Threading.Tasks.Task> |
UserUpdated
Fired when a user is updated.
Declaration
public event Func<SocketUser, SocketUser, Task> UserUpdated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketUser, SocketUser, System.Threading.Tasks.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 |
|---|---|
| System.Func<SocketUser, SocketVoiceState, SocketVoiceState, System.Threading.Tasks.Task> |
VoiceServerUpdated
Fired when the bot connects to a Discord voice server.
Declaration
public event Func<SocketVoiceServer, Task> VoiceServerUpdated
Event Type
| Type | Description |
|---|---|
| System.Func<SocketVoiceServer, System.Threading.Tasks.Task> |
Explicit Interface Implementations
| Improve this Doc View SourceIDiscordClient.CreateGuildAsync(String, IVoiceRegion, Stream, RequestOptions)
Creates a guild for the logged-in user who is in less than 10 active guilds.
Declaration
Task<IGuild> IDiscordClient.CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the new guild. |
| IVoiceRegion | region | The voice region to create the guild with. |
| System.IO.Stream | jpegIcon | The icon of the guild. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IGuild> | 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.
IDiscordClient.GetApplicationInfoAsync(RequestOptions)
Gets a Discord application information for the logged-in user.
Declaration
Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IApplication> | 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.
IDiscordClient.GetChannelAsync(UInt64, CacheMode, RequestOptions)
Gets a generic channel.
Declaration
Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | The snowflake identifier of the channel (e.g. |
| CacheMode | mode | The CacheMode that determines whether the object should be fetched from cache. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IChannel> | A task that represents the asynchronous get operation. The task result contains the channel associated
with the snowflake identifier; |
IDiscordClient.GetConnectionsAsync(RequestOptions)
Gets the connections that the user has set up.
Declaration
Task<IReadOnlyCollection<IConnection>> IDiscordClient.GetConnectionsAsync(RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IConnection>> | A task that represents the asynchronous get operation. The task result contains a read-only collection of connections. |
IDiscordClient.GetGuildAsync(UInt64, CacheMode, RequestOptions)
Gets a guild.
Declaration
Task<IGuild> IDiscordClient.GetGuildAsync(ulong id, CacheMode mode, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | The guild snowflake identifier. |
| CacheMode | mode | The CacheMode that determines whether the object should be fetched from cache. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IGuild> | A task that represents the asynchronous get operation. The task result contains the guild associated
with the snowflake identifier; |
IDiscordClient.GetGuildsAsync(CacheMode, RequestOptions)
Gets a collection of guilds that the user is currently in.
Declaration
Task<IReadOnlyCollection<IGuild>> IDiscordClient.GetGuildsAsync(CacheMode mode, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| CacheMode | mode | The CacheMode that determines whether the object should be fetched from cache. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IGuild>> | A task that represents the asynchronous get operation. The task result contains a read-only collection of guilds that the current user is in. |
IDiscordClient.GetInviteAsync(String, RequestOptions)
Gets an invite.
Declaration
Task<IInvite> IDiscordClient.GetInviteAsync(string inviteId, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | inviteId | The invitation identifier. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IInvite> | A task that represents the asynchronous get operation. The task result contains the invite information. |
IDiscordClient.GetPrivateChannelsAsync(CacheMode, RequestOptions)
Gets a collection of private channels opened in this session.
Declaration
Task<IReadOnlyCollection<IPrivateChannel>> IDiscordClient.GetPrivateChannelsAsync(CacheMode mode, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| CacheMode | mode | The CacheMode that determines whether the object should be fetched from cache. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IPrivateChannel>> | A task that represents the asynchronous get operation. The task result contains 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.
IDiscordClient.GetUserAsync(String, String, RequestOptions)
Gets a user.
Declaration
Task<IUser> IDiscordClient.GetUserAsync(string username, string discriminator, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | username | The name of the user (e.g. |
| System.String | discriminator | The discriminator value of the user (e.g. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IUser> | A task that represents the asynchronous get operation. The task result contains the user associated with
the name and the discriminator; |
IDiscordClient.GetUserAsync(UInt64, CacheMode, RequestOptions)
Gets a user.
Declaration
Task<IUser> IDiscordClient.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | The snowflake identifier of the user (e.g. |
| CacheMode | mode | The CacheMode that determines whether the object should be fetched from cache. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IUser> | A task that represents the asynchronous get operation. The task result contains the user associated with
the snowflake identifier; |
IDiscordClient.GetVoiceRegionAsync(String, RequestOptions)
Gets a voice region.
Declaration
Task<IVoiceRegion> IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | The identifier of the voice region (e.g. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IVoiceRegion> | A task that represents the asynchronous get operation. The task result contains the voice region
associated with the identifier; |
IDiscordClient.GetVoiceRegionsAsync(RequestOptions)
Gets a collection of the available voice regions.
Declaration
Task<IReadOnlyCollection<IVoiceRegion>> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IVoiceRegion>> | A task that represents the asynchronous get operation. The task result contains a read-only collection with all of the available voice regions in this session. |