Skip to main content

Class DiscordShardedClient

Assembly: Discord.Net.WebSocket.dll​
View Source​
Declaration
public class DiscordShardedClient : BaseSocketClient, IDiscordClient, IDisposable

Properties​

Latency​

Gets the estimated round-trip latency, in milliseconds, to the gateway server.

View Source​
Declaration
public override int Latency { get; protected set; }

Status​

Gets the status for the logged-in user.

View Source​
Declaration
public override UserStatus Status { get; protected set; }

Activity​

Gets the activity for the logged-in user.

View Source​
Declaration
public override IActivity Activity { get; protected set; }

DefaultStickerPacks​

Gets a collection of default stickers.

View Source​
Declaration
public override IReadOnlyCollection<StickerPack<SocketSticker>> DefaultStickerPacks { get; }

Guilds​

Gets a collection of guilds that the user is currently in.

View Source​
Declaration
public override IReadOnlyCollection<SocketGuild> Guilds { get; }

PrivateChannels​

Gets a collection of private channels opened in this session.

View Source​
Declaration
public override IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels { get; }

Shards​

View Source​
Declaration
public IReadOnlyCollection<DiscordSocketClient> Shards { get; }

Rest​

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

View Source​
Declaration
public override DiscordSocketRestClient Rest { get; }

CurrentUser​

View Source​
Declaration
public override SocketSelfUser CurrentUser { get; protected set; }

IDiscordClient.CurrentUser​

Gets the currently logged-in user.

View Source​
Declaration
ISelfUser IDiscordClient.CurrentUser { get; }

Methods​

StartAsync()​

Starts the connection between Discord and the client..

View Source​
Declaration
public override async Task StartAsync()
Returns​

System.Threading.Tasks.Task: A task that represents the asynchronous start operation.

StopAsync()​

Stops the connection between Discord and the client.

View Source​
Declaration
public override async Task StopAsync()
Returns​

System.Threading.Tasks.Task: A task that represents the asynchronous stop operation.

GetShard(Int32)​

View Source​
Declaration
public DiscordSocketClient GetShard(int id)
Returns​

Discord.WebSocket.DiscordSocketClient

Parameters​
TypeName
System.Int32id

GetShardIdFor(IGuild)​

View Source​
Declaration
public int GetShardIdFor(IGuild guild)
Returns​

System.Int32

Parameters​
TypeName
Discord.IGuildguild

GetShardFor(IGuild)​

View Source​
Declaration
public DiscordSocketClient GetShardFor(IGuild guild)
Returns​

Discord.WebSocket.DiscordSocketClient

Parameters​
TypeName
Discord.IGuildguild

GetApplicationInfoAsync(RequestOptions)​

Gets a Discord application information for the logged-in user.

View Source​
Declaration
public override async Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestApplication>: A task that represents the asynchronous get operation. The task result contains the application information.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe options to be used when sending the request.

GetGuild(UInt64)​

Gets a guild.

View Source​
Declaration
public override SocketGuild GetGuild(ulong id)
Returns​

Discord.WebSocket.SocketGuild: A WebSocket-based guild associated with the snowflake identifier; null when the guild cannot be found.

Parameters​
TypeNameDescription
System.UInt64idThe guild snowflake identifier.

GetChannel(UInt64)​

Gets a channel.

View Source​
Declaration
public override SocketChannel GetChannel(ulong id)
Returns​

Discord.WebSocket.SocketChannel: A generic WebSocket-based channel object (voice, text, category, etc.) associated with the identifier; null when the channel cannot be found.

Parameters​
TypeNameDescription
System.UInt64idThe snowflake identifier of the channel (e.g. 381889909113225237).

GetStickerAsync(UInt64, CacheMode, RequestOptions)​

Gets a sticker.

View Source​
Declaration
public override async Task<SocketSticker> GetStickerAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null)
Returns​

System.Threading.Tasks.Task<Discord.WebSocket.SocketSticker>: A Discord.WebSocket.SocketSticker if found, otherwise null.

Parameters​
TypeNameDescription
System.UInt64idThe id of the sticker to get.
Discord.CacheModemodeWhether or not to allow downloading from the api.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

GetUser(UInt64)​

Gets a generic user.

View Source​
Declaration
public override SocketUser GetUser(ulong id)
Returns​

Discord.WebSocket.SocketUser: A generic WebSocket-based user; null when the user cannot be found.

Parameters​
TypeNameDescription
System.UInt64idThe user snowflake ID.

GetUser(String, String)​

Gets a user.

View Source​
Declaration
public override SocketUser GetUser(string username, string discriminator)
Returns​

Discord.WebSocket.SocketUser: A generic WebSocket-based user; null when the user cannot be found.

Parameters​
TypeNameDescription
System.StringusernameThe name of the user.
System.StringdiscriminatorThe discriminator value of the user.

GetVoiceRegionsAsync(RequestOptions)​

Gets all voice regions.

View Source​
Declaration
public override async ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
Returns​

System.Threading.Tasks.ValueTask<System.Collections.Generic.IReadOnlyCollection<Discord.Rest.RestVoiceRegion>>: A task that contains a read-only collection of REST-based voice regions.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe options to be used when sending the request.

GetVoiceRegionAsync(String, RequestOptions)​

Gets a voice region.

View Source​
Declaration
public override async ValueTask<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null)
Returns​

System.Threading.Tasks.ValueTask<Discord.Rest.RestVoiceRegion>: A task that contains a REST-based voice region associated with the identifier; null if the voice region is not found.

Parameters​
TypeNameDescription
System.StringidThe identifier of the voice region (e.g. eu-central ).
Discord.RequestOptionsoptionsThe options to be used when sending the request.

DownloadUsersAsync(IEnumerable<IGuild>)​

Attempts to download users into the user cache for the selected guilds.

View Source​
Declaration
public override async Task DownloadUsersAsync(IEnumerable<IGuild> guilds)
Returns​

System.Threading.Tasks.Task: A task that represents the asynchronous download operation.

Parameters​
TypeNameDescription
System.Collections.Generic.IEnumerable<Discord.IGuild>guildsThe guilds to download the members from.

SetStatusAsync(UserStatus)​

Sets the current status of the user (e.g. Online, Do not Disturb).

View Source​
Declaration
public override async Task SetStatusAsync(UserStatus status)
Returns​

System.Threading.Tasks.Task: A task that represents the asynchronous set operation.

Parameters​
TypeNameDescription
Discord.UserStatusstatusThe new status to be set.

SetGameAsync(String, String, ActivityType)​

Sets the game of the user.

View Source​
Declaration
public override async Task SetGameAsync(string name, string streamUrl = null, ActivityType type = ActivityType.Playing)
Returns​

System.Threading.Tasks.Task: A task that represents the asynchronous set operation.

Parameters​
TypeNameDescription
System.StringnameThe name of the game.
System.StringstreamUrlIf streaming, the URL of the stream. Must be a valid Twitch URL.
Discord.ActivityTypetypeThe type of the game.

SetActivityAsync(IActivity)​

Sets the <code data-dev-comment-type="paramref" class="paramref">activity</code> of the logged-in user.

View Source​
Declaration
public override async Task SetActivityAsync(IActivity activity)
Returns​

System.Threading.Tasks.Task: A task that represents the asynchronous set operation.

Parameters​
TypeNameDescription
Discord.IActivityactivityThe activity to be set.

IDiscordClient.GetApplicationInfoAsync(RequestOptions)​

Gets a Discord application information for the logged-in user.

View Source​
Declaration
async Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IApplication>: A task that represents the asynchronous get operation. The task result contains the application information.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetChannelAsync(UInt64, CacheMode, RequestOptions)​

Gets a generic channel.

View Source​
Declaration
Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IChannel>: A task that represents the asynchronous get operation. The task result contains the channel associated with the snowflake identifier; null when the channel cannot be found.

Parameters​
TypeNameDescription
System.UInt64idThe snowflake identifier of the channel (e.g. 381889909113225237).
Discord.CacheModemodeThe Discord.CacheMode that determines whether the object should be fetched from cache.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetPrivateChannelsAsync(CacheMode, RequestOptions)​

Gets a collection of private channels opened in this session.

View Source​
Declaration
Task<IReadOnlyCollection<IPrivateChannel>> IDiscordClient.GetPrivateChannelsAsync(CacheMode mode, RequestOptions options)
Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.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.

Parameters​
TypeNameDescription
Discord.CacheModemodeThe Discord.CacheMode that determines whether the object should be fetched from cache.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetConnectionsAsync(RequestOptions)​

Gets the connections that the user has set up.

View Source​
Declaration
async Task<IReadOnlyCollection<IConnection>> IDiscordClient.GetConnectionsAsync(RequestOptions options)
Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.IConnection>>: A task that represents the asynchronous get operation. The task result contains a read-only collection of connections.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetInviteAsync(String, RequestOptions)​

Gets an invite.

View Source​
Declaration
async Task<IInvite> IDiscordClient.GetInviteAsync(string inviteId, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IInvite>: A task that represents the asynchronous get operation. The task result contains the invite information.

Parameters​
TypeNameDescription
System.StringinviteIdThe invitation identifier.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetGuildAsync(UInt64, CacheMode, RequestOptions)​

Gets a guild.

View Source​
Declaration
Task<IGuild> IDiscordClient.GetGuildAsync(ulong id, CacheMode mode, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IGuild>: A task that represents the asynchronous get operation. The task result contains the guild associated with the snowflake identifier; null when the guild cannot be found.

Parameters​
TypeNameDescription
System.UInt64idThe guild snowflake identifier.
Discord.CacheModemodeThe Discord.CacheMode that determines whether the object should be fetched from cache.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetGuildsAsync(CacheMode, RequestOptions)​

Gets a collection of guilds that the user is currently in.

View Source​
Declaration
Task<IReadOnlyCollection<IGuild>> IDiscordClient.GetGuildsAsync(CacheMode mode, RequestOptions options)
Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.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.

Parameters​
TypeNameDescription
Discord.CacheModemodeThe Discord.CacheMode that determines whether the object should be fetched from cache.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

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

Creates a guild for the logged-in user who is in less than 10 active guilds.

View Source​
Declaration
async Task<IGuild> IDiscordClient.CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IGuild>: A task that represents the asynchronous creation operation. The task result contains the created guild.

Parameters​
TypeNameDescription
System.StringnameThe name of the new guild.
Discord.IVoiceRegionregionThe voice region to create the guild with.
System.IO.StreamjpegIconThe icon of the guild.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetUserAsync(UInt64, CacheMode, RequestOptions)​

Gets a user.

View Source​
Declaration
Task<IUser> IDiscordClient.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IUser>: A task that represents the asynchronous get operation. The task result contains the user associated with the snowflake identifier; null if the user is not found.

Parameters​
TypeNameDescription
System.UInt64idThe snowflake identifier of the user (e.g. 168693960628371456).
Discord.CacheModemodeThe Discord.CacheMode that determines whether the object should be fetched from cache.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetUserAsync(String, String, RequestOptions)​

Gets a user.

View Source​
Declaration
Task<IUser> IDiscordClient.GetUserAsync(string username, string discriminator, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IUser>: A task that represents the asynchronous get operation. The task result contains the user associated with the name and the discriminator; null if the user is not found.

Parameters​
TypeNameDescription
System.StringusernameThe name of the user (e.g. Still).
System.StringdiscriminatorThe discriminator value of the user (e.g. 2876).
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetVoiceRegionsAsync(RequestOptions)​

Gets a collection of the available voice regions.

View Source​
Declaration
async Task<IReadOnlyCollection<IVoiceRegion>> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options)
Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.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.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetVoiceRegionAsync(String, RequestOptions)​

Gets a voice region.

View Source​
Declaration
async Task<IVoiceRegion> IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IVoiceRegion>: A task that represents the asynchronous get operation. The task result contains the voice region associated with the identifier; null if the voice region is not found.

Parameters​
TypeNameDescription
System.StringidThe identifier of the voice region (e.g. eu-central ).
Discord.RequestOptionsoptionsThe options to be used when sending the request.

Events​

ShardConnected​

Fired when a shard is connected to the Discord gateway.

View Source​
Declaration
public event Func<DiscordSocketClient, Task> ShardConnected
Event Type​

System.Func<Discord.WebSocket.DiscordSocketClient,System.Threading.Tasks.Task>

ShardDisconnected​

Fired when a shard is disconnected from the Discord gateway.

View Source​
Declaration
public event Func<Exception, DiscordSocketClient, Task> ShardDisconnected
Event Type​

System.Func<System.Exception,Discord.WebSocket.DiscordSocketClient,System.Threading.Tasks.Task>

ShardReady​

Fired when a guild data for a shard has finished downloading.

View Source​
Declaration
public event Func<DiscordSocketClient, Task> ShardReady
Event Type​

System.Func<Discord.WebSocket.DiscordSocketClient,System.Threading.Tasks.Task>

ShardLatencyUpdated​

Fired when a shard receives a heartbeat from the Discord gateway.

View Source​
Declaration
public event Func<int, int, DiscordSocketClient, Task> ShardLatencyUpdated
Event Type​

System.Func<System.Int32,System.Int32,Discord.WebSocket.DiscordSocketClient,System.Threading.Tasks.Task>

Implements​