Show / Hide Table of Contents

# Class DiscordSocketClient

Represents a WebSocket-based Discord client.

##### Inheritance

System.Object
BaseDiscordClient
BaseSocketClient
DiscordSocketClient

##### Implements

IDiscordClient
System.IDisposable

##### Inherited Members

BaseSocketClient.BaseConfig
BaseSocketClient.CurrentUser
BaseSocketClient.CreateGuildAsync(String, IVoiceRegion, Stream, RequestOptions)
BaseSocketClient.GetConnectionsAsync(RequestOptions)
BaseSocketClient.GetInviteAsync(String, RequestOptions)
BaseSocketClient.ChannelCreated
BaseSocketClient.ChannelDestroyed
BaseSocketClient.ChannelUpdated
BaseSocketClient.MessageReceived
BaseSocketClient.MessageDeleted
BaseSocketClient.MessagesBulkDeleted
BaseSocketClient.MessageUpdated
BaseSocketClient.ReactionAdded
BaseSocketClient.ReactionRemoved
BaseSocketClient.ReactionsCleared
BaseSocketClient.RoleCreated
BaseSocketClient.RoleDeleted
BaseSocketClient.RoleUpdated
BaseSocketClient.JoinedGuild
BaseSocketClient.LeftGuild
BaseSocketClient.GuildAvailable
BaseSocketClient.GuildUnavailable
BaseSocketClient.GuildMembersDownloaded
BaseSocketClient.GuildUpdated
BaseSocketClient.UserJoined
BaseSocketClient.UserLeft
BaseSocketClient.UserBanned
BaseSocketClient.UserUnbanned
BaseSocketClient.UserUpdated
BaseSocketClient.GuildMemberUpdated
BaseSocketClient.UserVoiceStateUpdated
BaseSocketClient.VoiceServerUpdated
BaseSocketClient.CurrentUserUpdated
BaseSocketClient.UserIsTyping
BaseSocketClient.RecipientAdded
BaseSocketClient.RecipientRemoved
BaseDiscordClient.Log
BaseDiscordClient.LoggedIn
BaseDiscordClient.LoggedOut
BaseDiscordClient.LoginState
BaseDiscordClient.TokenType
BaseDiscordClient.LoginAsync(TokenType, String, Boolean)
BaseDiscordClient.LogoutAsync()
BaseDiscordClient.Dispose()
BaseDiscordClient.GetRecommendedShardCountAsync(RequestOptions)
BaseDiscordClient.IDiscordClient.ConnectionState
BaseDiscordClient.IDiscordClient.CurrentUser
BaseDiscordClient.IDiscordClient.GetWebhookAsync(UInt64, RequestOptions)
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()

###### Namespace: Discord.WebSocket

###### Assembly: Discord.Net.WebSocket.dll

##### Syntax

    public class DiscordSocketClient : BaseSocketClient, IDiscordClient, IDisposable

### Constructors

| Improve this Doc View Source

#### DiscordSocketClient()

Initializes a new REST/WebSocket-based Discord client.

##### Declaration

    public DiscordSocketClient()

| Improve this Doc View Source

#### DiscordSocketClient(DiscordSocketConfig)

Initializes a new REST/WebSocket-based Discord client with the provided configuration.

##### Declaration

    public DiscordSocketClient(DiscordSocketConfig config)

##### Parameters

Type | Name | Description
--- | --- | ---
DiscordSocketConfig | config | The configuration to be used with the client.

### Properties

| Improve this Doc View Source

#### Activity

##### Declaration

    public override IActivity Activity { get; protected set; }

##### Property Value

Type | Description
--- | ---
IActivity |

##### Overrides

BaseSocketClient.Activity
| Improve this Doc View Source

#### ConnectionState

Gets the current connection state of this client.

##### Declaration

    public ConnectionState ConnectionState { get; }

##### Property Value

Type | Description
--- | ---
ConnectionState |

| Improve this Doc View Source

#### DMChannels

Gets a collection of direct message channels opened in this session.

##### Declaration

    public IReadOnlyCollection<SocketDMChannel> DMChannels { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IReadOnlyCollection<SocketDMChannel> | A collection of DM channels that have been opened in this session.

##### Remarks

This method returns a collection of currently opened direct message channels.

##### warning

This method will not return previously opened DM channels outside of the current session! If you have just started the client, this may return an empty collection.

| Improve this Doc View Source

#### GroupChannels

Gets a collection of group channels opened in this session.

##### Declaration

    public IReadOnlyCollection<SocketGroupChannel> GroupChannels { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IReadOnlyCollection<SocketGroupChannel> | A collection of group channels that have been opened in this session.

##### Remarks

This method returns a collection of currently opened group channels.

##### warning

This method will not return previously opened group channels outside of the current session! If you have just started the client, this may return an empty collection.

| Improve this Doc View Source

#### Guilds

##### Declaration

    public override IReadOnlyCollection<SocketGuild> Guilds { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IReadOnlyCollection<SocketGuild> |

##### Overrides

BaseSocketClient.Guilds
| Improve this Doc View Source

#### Latency

##### Declaration

    public override int Latency { get; protected set; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

##### Overrides

BaseSocketClient.Latency
| Improve this Doc View Source

#### PrivateChannels

##### Declaration

    public override IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IReadOnlyCollection<ISocketPrivateChannel> |

##### Overrides

BaseSocketClient.PrivateChannels
| Improve this Doc View Source

#### Rest

Provides access to a REST-only client with a shared state from this client.

##### Declaration

    public override DiscordSocketRestClient Rest { get; }

##### Property Value

Type | Description
--- | ---
DiscordSocketRestClient |

##### Overrides

BaseSocketClient.Rest
| Improve this Doc View Source

#### ShardId

Gets the shard of of this client.

##### Declaration

    public int ShardId { get; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### Status

##### Declaration

    public override UserStatus Status { get; protected set; }

##### Property Value

Type | Description
--- | ---
UserStatus |

##### Overrides

BaseSocketClient.Status
| Improve this Doc View Source

#### VoiceRegions

##### Declaration

    public override IReadOnlyCollection<RestVoiceRegion> VoiceRegions { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IReadOnlyCollection<RestVoiceRegion> |

##### Overrides

BaseSocketClient.VoiceRegions

### Methods

| Improve this Doc View Source

#### DownloadUsersAsync(IEnumerable<IGuild>)

##### Declaration

    public override Task DownloadUsersAsync(IEnumerable<IGuild> guilds)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Collections.Generic.IEnumerable<IGuild> | guilds |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

##### Overrides

BaseSocketClient.DownloadUsersAsync(IEnumerable<IGuild>)
| Improve this Doc View Source

#### GetApplicationInfoAsync(RequestOptions)

##### Declaration

    public override Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)

##### Parameters

Type | Name | Description
--- | --- | ---
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<RestApplication> |

##### Overrides

BaseSocketClient.GetApplicationInfoAsync(RequestOptions)
| Improve this Doc View Source

#### GetChannel(UInt64)

##### Declaration

    public override SocketChannel GetChannel(ulong id)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | id |

##### Returns

Type | Description
--- | ---
SocketChannel |

##### Overrides

BaseSocketClient.GetChannel(UInt64)
| Improve this Doc View Source

#### GetGuild(UInt64)

##### Declaration

    public override SocketGuild GetGuild(ulong id)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | id |

##### Returns

Type | Description
--- | ---
SocketGuild |

##### Overrides

BaseSocketClient.GetGuild(UInt64)
| Improve this Doc View Source

#### GetUser(String, String)

##### Declaration

    public override SocketUser GetUser(string username, string discriminator)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | username |
System.String | discriminator |

##### Returns

Type | Description
--- | ---
SocketUser |

##### Overrides

BaseSocketClient.GetUser(String, String)
| Improve this Doc View Source

#### GetUser(UInt64)

##### Declaration

    public override SocketUser GetUser(ulong id)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | id |

##### Returns

Type | Description
--- | ---
SocketUser |

##### Overrides

BaseSocketClient.GetUser(UInt64)
| Improve this Doc View Source

#### GetVoiceRegion(String)

##### Declaration

    public override RestVoiceRegion GetVoiceRegion(string id)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | id |

##### Returns

Type | Description
--- | ---
RestVoiceRegion |

##### Overrides

BaseSocketClient.GetVoiceRegion(String)
| Improve this Doc View Source

#### SetActivityAsync(IActivity)

##### Declaration

    public override Task SetActivityAsync(IActivity activity)

##### Parameters

Type | Name | Description
--- | --- | ---
IActivity | activity |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

##### Overrides

BaseSocketClient.SetActivityAsync(IActivity)
| Improve this Doc View Source

#### SetGameAsync(String, String, ActivityType)

##### Declaration

    public override Task SetGameAsync(string name, string streamUrl = null, ActivityType type = ActivityType.Playing)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name |
System.String | streamUrl |
ActivityType | type |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

##### Overrides

BaseSocketClient.SetGameAsync(String, String, ActivityType)

##### Examples

The following example sets the activity of the current user to the specified game name.

    await client.SetGameAsync("A Strange Game");

The following example sets the activity of the current user to a streaming status.

    await client.SetGameAsync("Great Stream 10/10", "https://twitch.tv/MyAmazingStream1337", ActivityType.Streaming);

| Improve this Doc View Source

#### SetStatusAsync(UserStatus)

##### Declaration

    public override Task SetStatusAsync(UserStatus status)

##### Parameters

Type | Name | Description
--- | --- | ---
UserStatus | status |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

##### Overrides

BaseSocketClient.SetStatusAsync(UserStatus)

##### Examples

The following example sets the status of the current user to Do Not Disturb.

    await client.SetStatusAsync(UserStatus.DoNotDisturb);

| Improve this Doc View Source

#### StartAsync()

##### Declaration

    public override Task StartAsync()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

##### Overrides

BaseSocketClient.StartAsync()
| Improve this Doc View Source

#### StopAsync()

##### Declaration

    public override Task StopAsync()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

##### Overrides

BaseSocketClient.StopAsync()

### Events

| Improve this Doc View Source

#### Connected

Fired when connected to the Discord gateway.

##### Declaration

    public event Func<Task> Connected

##### Event Type

Type | Description
--- | ---
System.Func<System.Threading.Tasks.Task> |

| Improve this Doc View Source

#### Disconnected

Fired when disconnected to the Discord gateway.

##### Declaration

    public event Func<Exception, Task> Disconnected

##### Event Type

Type | Description
--- | ---
System.Func<System.Exception, System.Threading.Tasks.Task> |

| Improve this Doc View Source

#### LatencyUpdated

Fired when a heartbeat is received from the Discord gateway.

##### Declaration

    public event Func<int, int, Task> LatencyUpdated

##### Event Type

Type | Description
--- | ---
System.Func<System.Int32, System.Int32, System.Threading.Tasks.Task> |

| Improve this Doc View Source

#### Ready

Fired when guild data has finished downloading.

##### Declaration

    public event Func<Task> Ready

##### Event Type

Type | Description
--- | ---
System.Func<System.Threading.Tasks.Task> |

### Explicit Interface Implementations

| Improve this Doc View Source

#### IDiscordClient.CreateGuildAsync(String, IVoiceRegion, Stream, RequestOptions)

##### Declaration

    Task<IGuild> IDiscordClient.CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name |
IVoiceRegion | region |
System.IO.Stream | jpegIcon |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IGuild> |

| Improve this Doc View Source

#### IDiscordClient.GetApplicationInfoAsync(RequestOptions)

##### Declaration

    Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IApplication> |

| Improve this Doc View Source

#### IDiscordClient.GetChannelAsync(UInt64, CacheMode, RequestOptions)

##### Declaration

    Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | id |
CacheMode | mode |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IChannel> |

| Improve this Doc View Source

#### IDiscordClient.GetConnectionsAsync(RequestOptions)

##### Declaration

    Task<IReadOnlyCollection<IConnection>> IDiscordClient.GetConnectionsAsync(RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IConnection>> |

| Improve this Doc View Source

#### IDiscordClient.GetDMChannelsAsync(CacheMode, RequestOptions)

##### Declaration

    Task<IReadOnlyCollection<IDMChannel>> IDiscordClient.GetDMChannelsAsync(CacheMode mode, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
CacheMode | mode |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IDMChannel>> |

| Improve this Doc View Source

#### IDiscordClient.GetGroupChannelsAsync(CacheMode, RequestOptions)

##### Declaration

    Task<IReadOnlyCollection<IGroupChannel>> IDiscordClient.GetGroupChannelsAsync(CacheMode mode, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
CacheMode | mode |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IGroupChannel>> |

| Improve this Doc View Source

#### IDiscordClient.GetGuildAsync(UInt64, CacheMode, RequestOptions)

##### Declaration

    Task<IGuild> IDiscordClient.GetGuildAsync(ulong id, CacheMode mode, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | id |
CacheMode | mode |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IGuild> |

| Improve this Doc View Source

#### IDiscordClient.GetGuildsAsync(CacheMode, RequestOptions)

##### Declaration

    Task<IReadOnlyCollection<IGuild>> IDiscordClient.GetGuildsAsync(CacheMode mode, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
CacheMode | mode |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IGuild>> |

| Improve this Doc View Source

#### IDiscordClient.GetInviteAsync(String, RequestOptions)

##### Declaration

    Task<IInvite> IDiscordClient.GetInviteAsync(string inviteId, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | inviteId |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IInvite> |

| Improve this Doc View Source

#### IDiscordClient.GetPrivateChannelsAsync(CacheMode, RequestOptions)

##### Declaration

    Task<IReadOnlyCollection<IPrivateChannel>> IDiscordClient.GetPrivateChannelsAsync(CacheMode mode, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
CacheMode | mode |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IPrivateChannel>> |

| Improve this Doc View Source

#### IDiscordClient.GetUserAsync(String, String, RequestOptions)

##### Declaration

    Task<IUser> IDiscordClient.GetUserAsync(string username, string discriminator, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | username |
System.String | discriminator |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IUser> |

| Improve this Doc View Source

#### IDiscordClient.GetUserAsync(UInt64, CacheMode, RequestOptions)

##### Declaration

    Task<IUser> IDiscordClient.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | id |
CacheMode | mode |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IUser> |

| Improve this Doc View Source

#### IDiscordClient.GetVoiceRegionAsync(String, RequestOptions)

##### Declaration

    Task<IVoiceRegion> IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | id |
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<IVoiceRegion> |

| Improve this Doc View Source

#### IDiscordClient.GetVoiceRegionsAsync(RequestOptions)

##### Declaration

    Task<IReadOnlyCollection<IVoiceRegion>> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options)

##### Parameters

Type | Name | Description
--- | --- | ---
RequestOptions | options |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IVoiceRegion>> |

| Improve this Doc View Source

#### IDiscordClient.StartAsync()

##### Declaration

    Task IDiscordClient.StartAsync()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

| Improve this Doc View Source

#### IDiscordClient.StopAsync()

##### Declaration

    Task IDiscordClient.StopAsync()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

### Implements

IDiscordClient
System.IDisposable