Class DiscordRestClient
Provides a client to send REST-based requests to Discord.
public class DiscordRestClient : BaseDiscordClient, IDiscordClient, IDisposable, IAsyncDisposable, IRestClientProvider
- Inheritance
-
DiscordRestClient
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
DiscordRestClient()
public DiscordRestClient()
DiscordRestClient(DiscordRestConfig)
Initializes a new DiscordRestClient with the provided configuration.
public DiscordRestClient(DiscordRestConfig config)
Parameters
config
DiscordRestConfigThe configuration to be used with the client.
Properties
CurrentUser
Gets the logged-in user.
public RestSelfUser CurrentUser { get; }
Property Value
Methods
AddReactionAsync(ulong, ulong, IEmote, RequestOptions)
public Task AddReactionAsync(ulong channelId, ulong messageId, IEmote emote, RequestOptions options = null)
Parameters
channelId
ulongmessageId
ulongemote
IEmoteoptions
RequestOptions
Returns
AddRoleAsync(ulong, ulong, ulong, RequestOptions)
public Task AddRoleAsync(ulong guildId, ulong userId, ulong roleId, RequestOptions options = null)
Parameters
guildId
ulonguserId
ulongroleId
ulongoptions
RequestOptions
Returns
BatchEditGuildCommandPermissions(ulong, IDictionary<ulong, ApplicationCommandPermission[]>, RequestOptions)
public Task<IReadOnlyCollection<GuildApplicationCommandPermission>> BatchEditGuildCommandPermissions(ulong guildId, IDictionary<ulong, ApplicationCommandPermission[]> permissions, RequestOptions options = null)
Parameters
guildId
ulongpermissions
IDictionary<ulong, ApplicationCommandPermission[]>options
RequestOptions
Returns
BulkOverwriteGlobalCommands(ApplicationCommandProperties[], RequestOptions)
public Task<IReadOnlyCollection<RestGlobalCommand>> BulkOverwriteGlobalCommands(ApplicationCommandProperties[] commandProperties, RequestOptions options = null)
Parameters
commandProperties
ApplicationCommandProperties[]options
RequestOptions
Returns
BulkOverwriteGuildCommands(ApplicationCommandProperties[], ulong, RequestOptions)
public Task<IReadOnlyCollection<RestGuildCommand>> BulkOverwriteGuildCommands(ApplicationCommandProperties[] commandProperties, ulong guildId, RequestOptions options = null)
Parameters
commandProperties
ApplicationCommandProperties[]guildId
ulongoptions
RequestOptions
Returns
ConsumeEntitlementAsync(ulong, RequestOptions)
Marks a given one-time purchase entitlement for the user as consumed.
public Task ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options = null)
Parameters
entitlementId
ulongThe id of the entitlement.
options
RequestOptionsThe options to be used when sending the request.
Returns
CreateApplicationEmoteAsync(string, Image, RequestOptions)
Creates an emote for the current application.
public Task<Emote> CreateApplicationEmoteAsync(string name, Image image, RequestOptions options = null)
Parameters
name
stringimage
Imageoptions
RequestOptions
Returns
CreateGlobalCommand(ApplicationCommandProperties, RequestOptions)
public Task<RestGlobalCommand> CreateGlobalCommand(ApplicationCommandProperties properties, RequestOptions options = null)
Parameters
properties
ApplicationCommandPropertiesoptions
RequestOptions
Returns
CreateGuildAsync(string, IVoiceRegion, Stream, RequestOptions)
public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null)
Parameters
name
stringregion
IVoiceRegionjpegIcon
Streamoptions
RequestOptions
Returns
CreateGuildCommand(ApplicationCommandProperties, ulong, RequestOptions)
public Task<RestGuildCommand> CreateGuildCommand(ApplicationCommandProperties properties, ulong guildId, RequestOptions options = null)
Parameters
properties
ApplicationCommandPropertiesguildId
ulongoptions
RequestOptions
Returns
CreateTestEntitlementAsync(ulong, ulong, SubscriptionOwnerType, RequestOptions)
Creates a test entitlement to a given SKU for a given guild or user.
public Task<RestEntitlement> CreateTestEntitlementAsync(ulong skuId, ulong ownerId, SubscriptionOwnerType ownerType, RequestOptions options = null)
Parameters
skuId
ulongownerId
ulongownerType
SubscriptionOwnerTypeoptions
RequestOptions
Returns
DeleteAllGlobalCommandsAsync(RequestOptions)
public Task DeleteAllGlobalCommandsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
DeleteApplicationEmoteAsync(ulong, RequestOptions)
Deletes an emote for the current application.
public Task DeleteApplicationEmoteAsync(ulong emoteId, RequestOptions options = null)
Parameters
emoteId
ulongoptions
RequestOptions
Returns
DeleteTestEntitlementAsync(ulong, RequestOptions)
Deletes a currently-active test entitlement.
public Task DeleteTestEntitlementAsync(ulong entitlementId, RequestOptions options = null)
Parameters
entitlementId
ulongoptions
RequestOptions
Returns
GetApplicationEmoteAsync(ulong, RequestOptions)
Gets an emote for the current application.
public Task<Emote> GetApplicationEmoteAsync(ulong emoteId, RequestOptions options = null)
Parameters
emoteId
ulongoptions
RequestOptions
Returns
GetApplicationEmotesAsync(RequestOptions)
Gets all emotes for the current application.
public Task<IReadOnlyCollection<Emote>> GetApplicationEmotesAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetApplicationInfoAsync(RequestOptions)
public Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetChannelAsync(ulong, RequestOptions)
public Task<RestChannel> GetChannelAsync(ulong id, RequestOptions options = null)
Parameters
id
ulongoptions
RequestOptions
Returns
GetConnectionsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetCurrentBotInfoAsync(RequestOptions)
public Task<RestApplication> GetCurrentBotInfoAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetCurrentUserAsync(RequestOptions)
public Task<RestSelfUser> GetCurrentUserAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetCurrentUserGuildMemberAsync(ulong, RequestOptions)
public Task<RestGuildUser> GetCurrentUserGuildMemberAsync(ulong guildId, RequestOptions options = null)
Parameters
guildId
ulongoptions
RequestOptions
Returns
GetDMChannelsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestDMChannel>> GetDMChannelsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetEntitlementsAsync(int?, ulong?, ulong?, bool, ulong?, ulong?, ulong[], RequestOptions)
Returns all entitlements for a given app, active and expired.
public IAsyncEnumerable<IReadOnlyCollection<IEntitlement>> GetEntitlementsAsync(int? limit = 100, ulong? afterId = null, ulong? beforeId = null, bool excludeEnded = false, ulong? guildId = null, ulong? userId = null, ulong[] skuIds = null, RequestOptions options = null)
Parameters
limit
int?afterId
ulong?beforeId
ulong?excludeEnded
boolguildId
ulong?userId
ulong?skuIds
ulong[]options
RequestOptions
Returns
GetGlobalApplicationCommands(bool, string, RequestOptions)
public Task<IReadOnlyCollection<RestGlobalCommand>> GetGlobalApplicationCommands(bool withLocalizations = false, string locale = null, RequestOptions options = null)
Parameters
withLocalizations
boollocale
stringoptions
RequestOptions
Returns
GetGroupChannelsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestGroupChannel>> GetGroupChannelsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetGuildApplicationCommands(ulong, bool, string, RequestOptions)
public Task<IReadOnlyCollection<RestGuildCommand>> GetGuildApplicationCommands(ulong guildId, bool withLocalizations = false, string locale = null, RequestOptions options = null)
Parameters
guildId
ulongwithLocalizations
boollocale
stringoptions
RequestOptions
Returns
GetGuildAsync(ulong, RequestOptions)
public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null)
Parameters
id
ulongoptions
RequestOptions
Returns
GetGuildAsync(ulong, bool, RequestOptions)
public Task<RestGuild> GetGuildAsync(ulong id, bool withCounts, RequestOptions options = null)
Parameters
id
ulongwithCounts
booloptions
RequestOptions
Returns
GetGuildSummariesAsync(RequestOptions)
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetGuildSummariesAsync(ulong, int, RequestOptions)
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null)
Parameters
fromGuildId
ulonglimit
intoptions
RequestOptions
Returns
GetGuildUserAsync(ulong, ulong, RequestOptions)
public Task<RestGuildUser> GetGuildUserAsync(ulong guildId, ulong id, RequestOptions options = null)
Parameters
guildId
ulongid
ulongoptions
RequestOptions
Returns
GetGuildWidgetAsync(ulong, RequestOptions)
public Task<RestGuildWidget?> GetGuildWidgetAsync(ulong id, RequestOptions options = null)
Parameters
id
ulongoptions
RequestOptions
Returns
GetGuildsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetGuildsAsync(bool, RequestOptions)
public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(bool withCounts, RequestOptions options = null)
Parameters
withCounts
booloptions
RequestOptions
Returns
GetInviteAsync(string, RequestOptions, ulong?)
public Task<RestInviteMetadata> GetInviteAsync(string inviteId, RequestOptions options = null, ulong? scheduledEventId = null)
Parameters
inviteId
stringoptions
RequestOptionsscheduledEventId
ulong?
Returns
GetPrivateChannelsAsync(RequestOptions)
public Task<IReadOnlyCollection<IRestPrivateChannel>> GetPrivateChannelsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetRoleConnectionMetadataRecordsAsync(RequestOptions)
public Task<IReadOnlyCollection<RoleConnectionMetadata>> GetRoleConnectionMetadataRecordsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetSKUSubscriptionAsync(ulong, ulong, RequestOptions)
Gets a subscription by its id.
public Task<RestSubscription> GetSKUSubscriptionAsync(ulong skuId, ulong subscriptionId, RequestOptions options = null)
Parameters
skuId
ulongsubscriptionId
ulongoptions
RequestOptions
Returns
GetSKUSubscriptionsAsync(ulong, int, ulong?, ulong?, ulong?, RequestOptions)
Returns all subscriptions for a given SKU.
public IAsyncEnumerable<IReadOnlyCollection<RestSubscription>> GetSKUSubscriptionsAsync(ulong skuId, int limit = 100, ulong? afterId = null, ulong? beforeId = null, ulong? userId = null, RequestOptions options = null)
Parameters
Returns
GetSKUsAsync(RequestOptions)
Returns all SKUs for a given application.
public Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetUserApplicationRoleConnectionAsync(ulong, RequestOptions)
public Task<RoleConnection> GetUserApplicationRoleConnectionAsync(ulong applicationId, RequestOptions options = null)
Parameters
applicationId
ulongoptions
RequestOptions
Returns
GetUserAsync(ulong, RequestOptions)
public Task<RestUser> GetUserAsync(ulong id, RequestOptions options = null)
Parameters
id
ulongoptions
RequestOptions
Returns
GetVoiceRegionAsync(string, RequestOptions)
public Task<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null)
Parameters
id
stringoptions
RequestOptions
Returns
GetVoiceRegionsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
GetWebhookAsync(ulong, RequestOptions)
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
Parameters
id
ulongoptions
RequestOptions
Returns
IsValidHttpInteraction(string, string, string, byte[])
public bool IsValidHttpInteraction(string publicKey, string signature, string timestamp, byte[] body)
Parameters
Returns
IsValidHttpInteraction(string, string, string, string)
public bool IsValidHttpInteraction(string publicKey, string signature, string timestamp, string body)
Parameters
Returns
ModifyApplicationEmoteAsync(ulong, Action<ApplicationEmoteProperties>, RequestOptions)
Modifies an emote for the current application.
public Task<Emote> ModifyApplicationEmoteAsync(ulong emoteId, Action<ApplicationEmoteProperties> args, RequestOptions options = null)
Parameters
emoteId
ulongargs
Action<ApplicationEmoteProperties>options
RequestOptions
Returns
ModifyCurrentBotApplicationAsync(Action<ModifyApplicationProperties>, RequestOptions)
public Task<RestApplication> ModifyCurrentBotApplicationAsync(Action<ModifyApplicationProperties> args, RequestOptions options = null)
Parameters
args
Action<ModifyApplicationProperties>options
RequestOptions
Returns
ModifyRoleConnectionMetadataRecordsAsync(ICollection<RoleConnectionMetadataProperties>, RequestOptions)
public Task<IReadOnlyCollection<RoleConnectionMetadata>> ModifyRoleConnectionMetadataRecordsAsync(ICollection<RoleConnectionMetadataProperties> metadata, RequestOptions options = null)
Parameters
metadata
ICollection<RoleConnectionMetadataProperties>options
RequestOptions
Returns
ModifyUserApplicationRoleConnectionAsync(ulong, RoleConnectionProperties, RequestOptions)
public Task<RoleConnection> ModifyUserApplicationRoleConnectionAsync(ulong applicationId, RoleConnectionProperties roleConnection, RequestOptions options = null)
Parameters
applicationId
ulongroleConnection
RoleConnectionPropertiesoptions
RequestOptions
Returns
ParseHttpInteractionAsync(string, string, string, byte[], Func<InteractionProperties, bool>)
Creates a RestInteraction from a http message.
public Task<RestInteraction> ParseHttpInteractionAsync(string publicKey, string signature, string timestamp, byte[] body, Func<InteractionProperties, bool> doApiCallOnCreation = null)
Parameters
publicKey
stringThe public key of your application
signature
stringThe signature sent with the interaction.
timestamp
stringThe timestamp sent with the interaction.
body
byte[]The body of the http message.
doApiCallOnCreation
Func<InteractionProperties, bool>
Returns
- Task<RestInteraction>
A RestInteraction that represents the incoming http interaction.
Exceptions
- BadSignatureException
Thrown when the signature doesn't match the public key.
ParseHttpInteractionAsync(string, string, string, string, Func<InteractionProperties, bool>)
Creates a RestInteraction from a http message.
public Task<RestInteraction> ParseHttpInteractionAsync(string publicKey, string signature, string timestamp, string body, Func<InteractionProperties, bool> doApiCallOnCreation = null)
Parameters
publicKey
stringThe public key of your application
signature
stringThe signature sent with the interaction.
timestamp
stringThe timestamp sent with the interaction.
body
stringThe body of the http message.
doApiCallOnCreation
Func<InteractionProperties, bool>
Returns
- Task<RestInteraction>
A RestInteraction that represents the incoming http interaction.
Exceptions
- BadSignatureException
Thrown when the signature doesn't match the public key.
RemoveAllReactionsAsync(ulong, ulong, RequestOptions)
public Task RemoveAllReactionsAsync(ulong channelId, ulong messageId, RequestOptions options = null)
Parameters
channelId
ulongmessageId
ulongoptions
RequestOptions
Returns
RemoveAllReactionsForEmoteAsync(ulong, ulong, IEmote, RequestOptions)
public Task RemoveAllReactionsForEmoteAsync(ulong channelId, ulong messageId, IEmote emote, RequestOptions options = null)
Parameters
channelId
ulongmessageId
ulongemote
IEmoteoptions
RequestOptions
Returns
RemoveReactionAsync(ulong, ulong, ulong, IEmote, RequestOptions)
public Task RemoveReactionAsync(ulong channelId, ulong messageId, ulong userId, IEmote emote, RequestOptions options = null)
Parameters
channelId
ulongmessageId
ulonguserId
ulongemote
IEmoteoptions
RequestOptions
Returns
RemoveRoleAsync(ulong, ulong, ulong, RequestOptions)
public Task RemoveRoleAsync(ulong guildId, ulong userId, ulong roleId, RequestOptions options = null)
Parameters
guildId
ulonguserId
ulongroleId
ulongoptions
RequestOptions