Class DiscordShardedClient
Assembly: Discord.Net.WebSocket.dll​
View Source​
public class DiscordShardedClient : BaseSocketClient, IDiscordClient, IDisposable
Properties​
Latency​
Gets the estimated round-trip latency, in milliseconds, to the gateway server.
View Source​
public override int Latency { get; protected set; }
Status​
Gets the status for the logged-in user.
View Source​
public override UserStatus Status { get; protected set; }
Activity​
Gets the activity for the logged-in user.
View Source​
public override IActivity Activity { get; protected set; }
DefaultStickerPacks​
Gets a collection of default stickers.
View Source​
public override IReadOnlyCollection<StickerPack<SocketSticker>> DefaultStickerPacks { get; }
Guilds​
Gets a collection of guilds that the user is currently in.
View Source​
public override IReadOnlyCollection<SocketGuild> Guilds { get; }
PrivateChannels​
Gets a collection of private channels opened in this session.
View Source​
public override IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels { get; }
Shards​
View Source​
public IReadOnlyCollection<DiscordSocketClient> Shards { get; }
Rest​
Provides access to a REST-only client with a shared state from this client.
View Source​
public override DiscordSocketRestClient Rest { get; }
CurrentUser​
View Source​
public override SocketSelfUser CurrentUser { get; protected set; }
IDiscordClient.CurrentUser​
Gets the currently logged-in user.
View Source​
ISelfUser IDiscordClient.CurrentUser { get; }
Methods​
StartAsync()​
Starts the connection between Discord and the client..
View Source​
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​
public override async Task StopAsync()
Returns​
System.Threading.Tasks.Task
:
A task that represents the asynchronous stop operation.
GetShard(Int32)​
View Source​
public DiscordSocketClient GetShard(int id)
Returns​
Discord.WebSocket.DiscordSocketClient
Parameters​
Type | Name |
---|---|
System.Int32 | id |
GetShardIdFor(IGuild)​
View Source​
public int GetShardIdFor(IGuild guild)
Returns​
System.Int32
Parameters​
Type | Name |
---|---|
Discord.IGuild | guild |
GetShardFor(IGuild)​
View Source​
public DiscordSocketClient GetShardFor(IGuild guild)
Returns​
Discord.WebSocket.DiscordSocketClient
Parameters​
Type | Name |
---|---|
Discord.IGuild | guild |
GetApplicationInfoAsync(RequestOptions)​
Gets a Discord application information for the logged-in user.
View Source​
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​
Type | Name | Description |
---|---|---|
Discord.RequestOptions | options | The options to be used when sending the request. |
GetGuild(UInt64)​
Gets a guild.
View Source​
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​
Type | Name | Description |
---|---|---|
System.UInt64 | id | The guild snowflake identifier. |
GetChannel(UInt64)​
Gets a channel.
View Source​
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​
Type | Name | Description |
---|---|---|
System.UInt64 | id | The snowflake identifier of the channel (e.g. 381889909113225237 ). |
GetStickerAsync(UInt64, CacheMode, RequestOptions)​
Gets a sticker.
View Source​
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​
Type | Name | Description |
---|---|---|
System.UInt64 | id | The id of the sticker to get. |
Discord.CacheMode | mode | Whether or not to allow downloading from the api. |
Discord.RequestOptions | options | The options to be used when sending the request. |
GetUser(UInt64)​
Gets a generic user.
View Source​
public override SocketUser GetUser(ulong id)
Returns​
Discord.WebSocket.SocketUser:
A generic WebSocket-based user; null
when the user cannot be found.
Parameters​
Type | Name | Description |
---|---|---|
System.UInt64 | id | The user snowflake ID. |
GetUser(String, String)​
Gets a user.
View Source​
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​
Type | Name | Description |
---|---|---|
System.String | username | The name of the user. |
System.String | discriminator | The discriminator value of the user. |
GetVoiceRegionsAsync(RequestOptions)​
Gets all voice regions.
View Source​
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​
Type | Name | Description |
---|---|---|
Discord.RequestOptions | options | The options to be used when sending the request. |
GetVoiceRegionAsync(String, RequestOptions)​
Gets a voice region.
View Source​
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​
Type | Name | Description |
---|---|---|
System.String | id | The identifier of the voice region (e.g. eu-central ). |
Discord.RequestOptions | options | The 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​
public override async Task DownloadUsersAsync(IEnumerable<IGuild> guilds)
Returns​
System.Threading.Tasks.Task
:
A task that represents the asynchronous download operation.
Parameters​
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Discord.IGuild> | guilds | The guilds to download the members from. |
SetStatusAsync(UserStatus)​
Sets the current status of the user (e.g. Online, Do not Disturb).
View Source​
public override async Task SetStatusAsync(UserStatus status)
Returns​
System.Threading.Tasks.Task
:
A task that represents the asynchronous set operation.
Parameters​
Type | Name | Description |
---|---|---|
Discord.UserStatus | status | The new status to be set. |
SetGameAsync(String, String, ActivityType)​
Sets the game of the user.
View Source​
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​
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. |
Discord.ActivityType | type | The 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​
public override async Task SetActivityAsync(IActivity activity)
Returns​
System.Threading.Tasks.Task
:
A task that represents the asynchronous set operation.
Parameters​
Type | Name | Description |
---|---|---|
Discord.IActivity | activity | The activity to be set. |
IDiscordClient.GetApplicationInfoAsync(RequestOptions)​
Gets a Discord application information for the logged-in user.
View Source​
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​
Type | Name | Description |
---|---|---|
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetChannelAsync(UInt64, CacheMode, RequestOptions)​
Gets a generic channel.
View Source​
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​
Type | Name | Description |
---|---|---|
System.UInt64 | id | The snowflake identifier of the channel (e.g. 381889909113225237 ). |
Discord.CacheMode | mode | The Discord.CacheMode that determines whether the object should be fetched from cache. |
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetPrivateChannelsAsync(CacheMode, RequestOptions)​
Gets a collection of private channels opened in this session.
View Source​
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​
Type | Name | Description |
---|---|---|
Discord.CacheMode | mode | The Discord.CacheMode that determines whether the object should be fetched from cache. |
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetConnectionsAsync(RequestOptions)​
Gets the connections that the user has set up.
View Source​
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​
Type | Name | Description |
---|---|---|
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetInviteAsync(String, RequestOptions)​
Gets an invite.
View Source​
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​
Type | Name | Description |
---|---|---|
System.String | inviteId | The invitation identifier. |
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetGuildAsync(UInt64, CacheMode, RequestOptions)​
Gets a guild.
View Source​
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​
Type | Name | Description |
---|---|---|
System.UInt64 | id | The guild snowflake identifier. |
Discord.CacheMode | mode | The Discord.CacheMode that determines whether the object should be fetched from cache. |
Discord.RequestOptions | options | The 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​
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​
Type | Name | Description |
---|---|---|
Discord.CacheMode | mode | The Discord.CacheMode that determines whether the object should be fetched from cache. |
Discord.RequestOptions | options | The 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​
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​
Type | Name | Description |
---|---|---|
System.String | name | The name of the new guild. |
Discord.IVoiceRegion | region | The voice region to create the guild with. |
System.IO.Stream | jpegIcon | The icon of the guild. |
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetUserAsync(UInt64, CacheMode, RequestOptions)​
Gets a user.
View Source​
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​
Type | Name | Description |
---|---|---|
System.UInt64 | id | The snowflake identifier of the user (e.g. 168693960628371456 ). |
Discord.CacheMode | mode | The Discord.CacheMode that determines whether the object should be fetched from cache. |
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetUserAsync(String, String, RequestOptions)​
Gets a user.
View Source​
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​
Type | Name | Description |
---|---|---|
System.String | username | The name of the user (e.g. Still ). |
System.String | discriminator | The discriminator value of the user (e.g. 2876 ). |
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetVoiceRegionsAsync(RequestOptions)​
Gets a collection of the available voice regions.
View Source​
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​
Type | Name | Description |
---|---|---|
Discord.RequestOptions | options | The options to be used when sending the request. |
IDiscordClient.GetVoiceRegionAsync(String, RequestOptions)​
Gets a voice region.
View Source​
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​
Type | Name | Description |
---|---|---|
System.String | id | The identifier of the voice region (e.g. eu-central ). |
Discord.RequestOptions | options | The options to be used when sending the request. |
Events​
ShardConnected​
Fired when a shard is connected to the Discord gateway.
View Source​
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​
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​
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​
public event Func<int, int, DiscordSocketClient, Task> ShardLatencyUpdated
Event Type​
System.Func<System.Int32,System.Int32,Discord.WebSocket.DiscordSocketClient,System.Threading.Tasks.Task>
Implements​
- Discord.IDiscordClient
System.IDisposable