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
configDiscordRestConfigThe 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
channelIdulongmessageIdulongemoteIEmoteoptionsRequestOptions
Returns
AddRoleAsync(ulong, ulong, ulong, RequestOptions)
public Task AddRoleAsync(ulong guildId, ulong userId, ulong roleId, RequestOptions options = null)
Parameters
guildIdulonguserIdulongroleIdulongoptionsRequestOptions
Returns
BatchEditGuildCommandPermissions(ulong, IDictionary<ulong, ApplicationCommandPermission[]>, RequestOptions)
public Task<IReadOnlyCollection<GuildApplicationCommandPermission>> BatchEditGuildCommandPermissions(ulong guildId, IDictionary<ulong, ApplicationCommandPermission[]> permissions, RequestOptions options = null)
Parameters
guildIdulongpermissionsIDictionary<ulong, ApplicationCommandPermission[]>optionsRequestOptions
Returns
BulkOverwriteGlobalCommands(ApplicationCommandProperties[], RequestOptions)
public Task<IReadOnlyCollection<RestGlobalCommand>> BulkOverwriteGlobalCommands(ApplicationCommandProperties[] commandProperties, RequestOptions options = null)
Parameters
commandPropertiesApplicationCommandProperties[]optionsRequestOptions
Returns
BulkOverwriteGuildCommands(ApplicationCommandProperties[], ulong, RequestOptions)
public Task<IReadOnlyCollection<RestGuildCommand>> BulkOverwriteGuildCommands(ApplicationCommandProperties[] commandProperties, ulong guildId, RequestOptions options = null)
Parameters
commandPropertiesApplicationCommandProperties[]guildIdulongoptionsRequestOptions
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
entitlementIdulongThe id of the entitlement.
optionsRequestOptionsThe 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
namestringimageImageoptionsRequestOptions
Returns
CreateGlobalCommand(ApplicationCommandProperties, RequestOptions)
public Task<RestGlobalCommand> CreateGlobalCommand(ApplicationCommandProperties properties, RequestOptions options = null)
Parameters
propertiesApplicationCommandPropertiesoptionsRequestOptions
Returns
CreateGuildAsync(string, IVoiceRegion, Stream, RequestOptions)
public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null)
Parameters
namestringregionIVoiceRegionjpegIconStreamoptionsRequestOptions
Returns
CreateGuildCommand(ApplicationCommandProperties, ulong, RequestOptions)
public Task<RestGuildCommand> CreateGuildCommand(ApplicationCommandProperties properties, ulong guildId, RequestOptions options = null)
Parameters
propertiesApplicationCommandPropertiesguildIdulongoptionsRequestOptions
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
skuIdulongownerIdulongownerTypeSubscriptionOwnerTypeoptionsRequestOptions
Returns
DeleteAllGlobalCommandsAsync(RequestOptions)
public Task DeleteAllGlobalCommandsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
DeleteApplicationEmoteAsync(ulong, RequestOptions)
Deletes an emote for the current application.
public Task DeleteApplicationEmoteAsync(ulong emoteId, RequestOptions options = null)
Parameters
emoteIdulongoptionsRequestOptions
Returns
DeleteTestEntitlementAsync(ulong, RequestOptions)
Deletes a currently-active test entitlement.
public Task DeleteTestEntitlementAsync(ulong entitlementId, RequestOptions options = null)
Parameters
entitlementIdulongoptionsRequestOptions
Returns
GetApplicationEmoteAsync(ulong, RequestOptions)
Gets an emote for the current application.
public Task<Emote> GetApplicationEmoteAsync(ulong emoteId, RequestOptions options = null)
Parameters
emoteIdulongoptionsRequestOptions
Returns
GetApplicationEmotesAsync(RequestOptions)
Gets all emotes for the current application.
public Task<IReadOnlyCollection<Emote>> GetApplicationEmotesAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetApplicationInfoAsync(RequestOptions)
public Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetChannelAsync(ulong, RequestOptions)
public Task<RestChannel> GetChannelAsync(ulong id, RequestOptions options = null)
Parameters
idulongoptionsRequestOptions
Returns
GetConnectionsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetCurrentBotInfoAsync(RequestOptions)
public Task<RestApplication> GetCurrentBotInfoAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetCurrentUserAsync(RequestOptions)
public Task<RestSelfUser> GetCurrentUserAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetCurrentUserGuildMemberAsync(ulong, RequestOptions)
public Task<RestGuildUser> GetCurrentUserGuildMemberAsync(ulong guildId, RequestOptions options = null)
Parameters
guildIdulongoptionsRequestOptions
Returns
GetDMChannelsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestDMChannel>> GetDMChannelsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetEntitlementsAsync(int?, ulong?, ulong?, bool, ulong?, ulong?, ulong[], RequestOptions, bool?)
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, bool? excludeDeleted = null)
Parameters
limitint?afterIdulong?beforeIdulong?excludeEndedboolguildIdulong?userIdulong?skuIdsulong[]optionsRequestOptionsexcludeDeletedbool?
Returns
GetGlobalApplicationCommands(bool, string, RequestOptions)
public Task<IReadOnlyCollection<RestGlobalCommand>> GetGlobalApplicationCommands(bool withLocalizations = false, string locale = null, RequestOptions options = null)
Parameters
withLocalizationsboollocalestringoptionsRequestOptions
Returns
GetGroupChannelsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestGroupChannel>> GetGroupChannelsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetGuildApplicationCommands(ulong, bool, string, RequestOptions)
public Task<IReadOnlyCollection<RestGuildCommand>> GetGuildApplicationCommands(ulong guildId, bool withLocalizations = false, string locale = null, RequestOptions options = null)
Parameters
guildIdulongwithLocalizationsboollocalestringoptionsRequestOptions
Returns
GetGuildAsync(ulong, RequestOptions)
public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null)
Parameters
idulongoptionsRequestOptions
Returns
GetGuildAsync(ulong, bool, RequestOptions)
public Task<RestGuild> GetGuildAsync(ulong id, bool withCounts, RequestOptions options = null)
Parameters
idulongwithCountsbooloptionsRequestOptions
Returns
GetGuildSummariesAsync(RequestOptions)
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetGuildSummariesAsync(ulong, int, RequestOptions)
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null)
Parameters
fromGuildIdulonglimitintoptionsRequestOptions
Returns
GetGuildUserAsync(ulong, ulong, RequestOptions)
public Task<RestGuildUser> GetGuildUserAsync(ulong guildId, ulong id, RequestOptions options = null)
Parameters
guildIdulongidulongoptionsRequestOptions
Returns
GetGuildWidgetAsync(ulong, RequestOptions)
public Task<RestGuildWidget?> GetGuildWidgetAsync(ulong id, RequestOptions options = null)
Parameters
idulongoptionsRequestOptions
Returns
GetGuildsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetGuildsAsync(bool, RequestOptions)
public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(bool withCounts, RequestOptions options = null)
Parameters
withCountsbooloptionsRequestOptions
Returns
GetInviteAsync(string, RequestOptions, ulong?)
public Task<RestInviteMetadata> GetInviteAsync(string inviteId, RequestOptions options = null, ulong? scheduledEventId = null)
Parameters
inviteIdstringoptionsRequestOptionsscheduledEventIdulong?
Returns
GetPrivateChannelsAsync(RequestOptions)
public Task<IReadOnlyCollection<IRestPrivateChannel>> GetPrivateChannelsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetRoleConnectionMetadataRecordsAsync(RequestOptions)
public Task<IReadOnlyCollection<RoleConnectionMetadata>> GetRoleConnectionMetadataRecordsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetSKUSubscriptionAsync(ulong, ulong, RequestOptions)
Gets a subscription by its id.
public Task<RestSubscription> GetSKUSubscriptionAsync(ulong skuId, ulong subscriptionId, RequestOptions options = null)
Parameters
skuIdulongsubscriptionIdulongoptionsRequestOptions
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
optionsRequestOptions
Returns
GetUserApplicationRoleConnectionAsync(ulong, RequestOptions)
public Task<RoleConnection> GetUserApplicationRoleConnectionAsync(ulong applicationId, RequestOptions options = null)
Parameters
applicationIdulongoptionsRequestOptions
Returns
GetUserAsync(ulong, RequestOptions)
public Task<RestUser> GetUserAsync(ulong id, RequestOptions options = null)
Parameters
idulongoptionsRequestOptions
Returns
GetVoiceRegionAsync(string, RequestOptions)
public Task<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null)
Parameters
idstringoptionsRequestOptions
Returns
GetVoiceRegionsAsync(RequestOptions)
public Task<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
Parameters
optionsRequestOptions
Returns
GetWebhookAsync(ulong, RequestOptions)
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
Parameters
idulongoptionsRequestOptions
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
emoteIdulongargsAction<ApplicationEmoteProperties>optionsRequestOptions
Returns
ModifyCurrentBotApplicationAsync(Action<ModifyApplicationProperties>, RequestOptions)
public Task<RestApplication> ModifyCurrentBotApplicationAsync(Action<ModifyApplicationProperties> args, RequestOptions options = null)
Parameters
argsAction<ModifyApplicationProperties>optionsRequestOptions
Returns
ModifyRoleConnectionMetadataRecordsAsync(ICollection<RoleConnectionMetadataProperties>, RequestOptions)
public Task<IReadOnlyCollection<RoleConnectionMetadata>> ModifyRoleConnectionMetadataRecordsAsync(ICollection<RoleConnectionMetadataProperties> metadata, RequestOptions options = null)
Parameters
metadataICollection<RoleConnectionMetadataProperties>optionsRequestOptions
Returns
ModifyUserApplicationRoleConnectionAsync(ulong, RoleConnectionProperties, RequestOptions)
public Task<RoleConnection> ModifyUserApplicationRoleConnectionAsync(ulong applicationId, RoleConnectionProperties roleConnection, RequestOptions options = null)
Parameters
applicationIdulongroleConnectionRoleConnectionPropertiesoptionsRequestOptions
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
publicKeystringThe public key of your application
signaturestringThe signature sent with the interaction.
timestampstringThe timestamp sent with the interaction.
bodybyte[]The body of the http message.
doApiCallOnCreationFunc<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
publicKeystringThe public key of your application
signaturestringThe signature sent with the interaction.
timestampstringThe timestamp sent with the interaction.
bodystringThe body of the http message.
doApiCallOnCreationFunc<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
channelIdulongmessageIdulongoptionsRequestOptions
Returns
RemoveAllReactionsForEmoteAsync(ulong, ulong, IEmote, RequestOptions)
public Task RemoveAllReactionsForEmoteAsync(ulong channelId, ulong messageId, IEmote emote, RequestOptions options = null)
Parameters
channelIdulongmessageIdulongemoteIEmoteoptionsRequestOptions
Returns
RemoveReactionAsync(ulong, ulong, ulong, IEmote, RequestOptions)
public Task RemoveReactionAsync(ulong channelId, ulong messageId, ulong userId, IEmote emote, RequestOptions options = null)
Parameters
channelIdulongmessageIdulonguserIdulongemoteIEmoteoptionsRequestOptions
Returns
RemoveRoleAsync(ulong, ulong, ulong, RequestOptions)
public Task RemoveRoleAsync(ulong guildId, ulong userId, ulong roleId, RequestOptions options = null)
Parameters
guildIdulonguserIdulongroleIdulongoptionsRequestOptions