Class DiscordRestClient
Provides a client to send REST-based requests to Discord.
Inherited Members
Namespace: Discord.Rest
Assembly: Discord.Net.Rest.dll
Syntax
public class DiscordRestClient : BaseDiscordClient, IDiscordClient, IDisposable
Constructors
| Improve this Doc View SourceDiscordRestClient()
Declaration
public DiscordRestClient()
DiscordRestClient(DiscordRestConfig)
Initializes a new DiscordRestClient with the provided configuration.
Declaration
public DiscordRestClient(DiscordRestConfig config)
Parameters
| Type | Name | Description |
|---|---|---|
| DiscordRestConfig | config | The configuration to be used with the client. |
Properties
| Improve this Doc View SourceCurrentUser
Gets the logged-in user.
Declaration
public RestSelfUser CurrentUser { get; }
Property Value
| Type | Description |
|---|---|
| RestSelfUser |
Methods
| Improve this Doc View SourceCreateGuildAsync(String, IVoiceRegion, Stream, RequestOptions)
Declaration
public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| IVoiceRegion | region | |
| System.IO.Stream | jpegIcon | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestGuild> |
GetApplicationInfoAsync(RequestOptions)
Declaration
public Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestApplication> |
GetChannelAsync(UInt64, RequestOptions)
Declaration
public Task<RestChannel> GetChannelAsync(ulong id, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestChannel> |
GetConnectionsAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<RestConnection>> |
GetDMChannelsAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<RestDMChannel>> GetDMChannelsAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<RestDMChannel>> |
GetGroupChannelsAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<RestGroupChannel>> GetGroupChannelsAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<RestGroupChannel>> |
GetGuildAsync(UInt64, RequestOptions)
Declaration
public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestGuild> |
GetGuildEmbedAsync(UInt64, RequestOptions)
Declaration
public Task<RestGuildEmbed?> GetGuildEmbedAsync(ulong id, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Nullable<RestGuildEmbed>> |
GetGuildsAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<RestGuild>> |
GetGuildSummariesAsync(RequestOptions)
Declaration
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.IReadOnlyCollection<RestUserGuild>> |
GetGuildSummariesAsync(UInt64, Int32, RequestOptions)
Declaration
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | fromGuildId | |
| System.Int32 | limit | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.IReadOnlyCollection<RestUserGuild>> |
GetGuildUserAsync(UInt64, UInt64, RequestOptions)
Declaration
public Task<RestGuildUser> GetGuildUserAsync(ulong guildId, ulong id, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | guildId | |
| System.UInt64 | id | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestGuildUser> |
GetInviteAsync(String, RequestOptions)
Declaration
public Task<RestInviteMetadata> GetInviteAsync(string inviteId, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | inviteId | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestInviteMetadata> |
GetPrivateChannelsAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<IRestPrivateChannel>> GetPrivateChannelsAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<IRestPrivateChannel>> |
GetUserAsync(UInt64, RequestOptions)
Declaration
public Task<RestUser> GetUserAsync(ulong id, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestUser> |
GetVoiceRegionAsync(String, RequestOptions)
Declaration
public Task<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestVoiceRegion> |
GetVoiceRegionsAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<RestVoiceRegion>> |
GetWebhookAsync(UInt64, RequestOptions)
Declaration
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | |
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestWebhook> |
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.GetDMChannelsAsync(CacheMode, RequestOptions)
Gets a collection of direct message channels opened in this session.
Declaration
Task<IReadOnlyCollection<IDMChannel>> IDiscordClient.GetDMChannelsAsync(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<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. |
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.
IDiscordClient.GetGroupChannelsAsync(CacheMode, RequestOptions)
Gets a collection of group channels opened in this session.
Declaration
Task<IReadOnlyCollection<IGroupChannel>> IDiscordClient.GetGroupChannelsAsync(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<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. |
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.
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)
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> |
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(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. |
IDiscordClient.GetWebhookAsync(UInt64, RequestOptions)
Gets a webhook available.
Declaration
Task<IWebhook> IDiscordClient.GetWebhookAsync(ulong id, RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id | The identifier of the webhook. |
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IWebhook> | A task that represents the asynchronous get operation. The task result contains a webhook associated
with the identifier; |