Skip to main content

Class BaseDiscordClient

Assembly: Discord.Net.Rest.dll​
View Source​
Declaration
public abstract class BaseDiscordClient : IDiscordClient, IDisposable

Properties​

LoginState​

Gets the login state of the client.

View Source​
Declaration
public LoginState LoginState { get; }

CurrentUser​

Gets the logged-in user.

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

TokenType​

Gets the token type of the logged-in user.

View Source​
Declaration
public TokenType TokenType { get; }

IDiscordClient.ConnectionState​

Gets the current state of connection.

View Source​
Declaration
ConnectionState IDiscordClient.ConnectionState { get; }

IDiscordClient.CurrentUser​

Gets the currently logged-in user.

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

Methods​

LoginAsync(TokenType, String, Boolean)​

View Source​
Declaration
public async Task LoginAsync(TokenType tokenType, string token, bool validateToken = true)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeName
Discord.TokenTypetokenType
System.Stringtoken
System.BooleanvalidateToken

LogoutAsync()​

View Source​
Declaration
public async Task LogoutAsync()
Returns​

System.Threading.Tasks.Task

Dispose()​

View Source​
Declaration
public void Dispose()

GetRecommendedShardCountAsync(RequestOptions)​

Gets the recommended shard count as suggested by Discord.

View Source​
Declaration
public Task<int> GetRecommendedShardCountAsync(RequestOptions options = null)
Returns​

System.Threading.Tasks.Task<System.Int32>: A task that represents the asynchronous get operation. The task result contains an System.Int32 that represents the number of shards that should be used with this account.

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

GetBotGatewayAsync(RequestOptions)​

Gets the gateway information related to the bot.

View Source​
Declaration
public Task<BotGateway> GetBotGatewayAsync(RequestOptions options = null)
Returns​

System.Threading.Tasks.Task<Discord.BotGateway>: A task that represents the asynchronous get operation. The task result contains a Discord.BotGateway that represents the gateway information related to the bot.

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

IDiscordClient.GetApplicationInfoAsync(RequestOptions)​

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

View Source​
Declaration
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.GetDMChannelsAsync(CacheMode, RequestOptions)​

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

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

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.IDMChannel>>: A task that represents the asynchronous get operation. The task result contains a read-only collection of direct-message 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.GetGroupChannelsAsync(CacheMode, RequestOptions)​

Gets a collection of group channels opened in this session.

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

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.IGroupChannel>>: A task that represents the asynchronous get operation. The task result contains a read-only collection of group 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
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
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
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
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
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.

IDiscordClient.GetWebhookAsync(UInt64, RequestOptions)​

Gets a webhook available.

View Source​
Declaration
Task<IWebhook> IDiscordClient.GetWebhookAsync(ulong id, RequestOptions options)
Returns​

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

Parameters​
TypeNameDescription
System.UInt64idThe identifier of the webhook.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetGlobalApplicationCommandAsync(UInt64, RequestOptions)​

Gets a global application command.

View Source​
Declaration
Task<IApplicationCommand> IDiscordClient.GetGlobalApplicationCommandAsync(ulong id, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IApplicationCommand>: A task that represents the asynchronous get operation. The task result contains the application command if found, otherwise null.

Parameters​
TypeNameDescription
System.UInt64idThe id of the command.
Discord.RequestOptionsoptionsThe options to be used when sending the request.

IDiscordClient.GetGlobalApplicationCommandsAsync(RequestOptions)​

Gets a collection of all global commands.

View Source​
Declaration
Task<IReadOnlyCollection<IApplicationCommand>> IDiscordClient.GetGlobalApplicationCommandsAsync(RequestOptions options)
Returns​

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

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

IDiscordClient.CreateGlobalApplicationCommand(ApplicationCommandProperties, RequestOptions)​

View Source​
Declaration
Task<IApplicationCommand> IDiscordClient.CreateGlobalApplicationCommand(ApplicationCommandProperties properties, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IApplicationCommand>

Parameters​
TypeName
Discord.ApplicationCommandPropertiesproperties
Discord.RequestOptionsoptions

IDiscordClient.BulkOverwriteGlobalApplicationCommand(ApplicationCommandProperties[], RequestOptions)​

View Source​
Declaration
Task<IReadOnlyCollection<IApplicationCommand>> IDiscordClient.BulkOverwriteGlobalApplicationCommand(ApplicationCommandProperties[] properties, RequestOptions options)
Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<Discord.IApplicationCommand>>

Parameters​
TypeName
Discord.ApplicationCommandProperties[]properties
Discord.RequestOptionsoptions

IDiscordClient.StartAsync()​

Starts the connection between Discord and the client..

View Source​
Declaration
Task IDiscordClient.StartAsync()
Returns​

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

IDiscordClient.StopAsync()​

Stops the connection between Discord and the client.

View Source​
Declaration
Task IDiscordClient.StopAsync()
Returns​

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

Events​

Log​

View Source​
Declaration
public event Func<LogMessage, Task> Log
Event Type​

System.Func<Discord.LogMessage,System.Threading.Tasks.Task>

LoggedIn​

View Source​
Declaration
public event Func<Task> LoggedIn
Event Type​

System.Func<System.Threading.Tasks.Task>

LoggedOut​

View Source​
Declaration
public event Func<Task> LoggedOut
Event Type​

System.Func<System.Threading.Tasks.Task>

Implements​

Extension Methods​

  • Discord.Rest.BaseDiscordClient.Discord.Rest.ClientExtensions.AddGuildUserAsync(System.UInt64,System.UInt64,System.String,System.Action{Discord.AddGuildUserProperties},Discord.RequestOptions)