Class RestInteraction
Represents a REST-based interaction.
public abstract class RestInteraction : RestEntity<ulong>, IDiscordInteraction, ISnowflakeEntity, IEntity<ulong>
- Inheritance
-
RestInteraction
- Implements
- Derived
- Inherited Members
- Extension Methods
Properties
ApplicationId
Gets the ID of the application this interaction is for.
public ulong ApplicationId { get; }
Property Value
Channel
Gets the channel that this interaction was executed in.
public IRestMessageChannel Channel { get; }
Property Value
Remarks
This property will be null if APIOnRestInteractionCreation is set to false. Call GetChannelAsync(RequestOptions) to set this property and get the interaction channel.
ChannelId
Gets the ID of the channel this interaction was executed in.
public ulong? ChannelId { get; }
Property Value
Remarks
This property returns null if the interaction is a REST ping interaction.
ContextType
Gets the context this interaction was created in. null if context type is unknown.
public InteractionContextType? ContextType { get; }
Property Value
CreatedAt
Gets when the snowflake was created.
public DateTimeOffset CreatedAt { get; }
Property Value
- DateTimeOffset
A DateTimeOffset representing when the entity was first created.
Data
Gets the data sent within this interaction.
public IDiscordInteractionData Data { get; }
Property Value
Entitlements
Gets entitlements for the invoking user.
public IReadOnlyCollection<RestEntitlement> Entitlements { get; }
Property Value
Guild
Gets the guild this interaction was executed in if applicable.
public RestGuild Guild { get; }
Property Value
Remarks
This property will be null if APIOnRestInteractionCreation is set to false or if the interaction was not executed in a guild.
GuildId
Gets the ID of the guild this interaction was executed in.
public ulong? GuildId { get; }
Property Value
Remarks
This property returns null if the interaction was not executed in a guild.
GuildLocale
Gets the preferred locale of the guild this interaction was executed in. null if not executed in a guild.
public string GuildLocale { get; }
Property Value
Remarks
Non-community guilds (With no locale setting available) will have en-US as the default value sent by Discord.
HasResponded
Gets whether or not this interaction has been responded to.
public bool HasResponded { get; protected set; }
Property Value
Remarks
This property is locally set -- if you're running multiple bots off the same token then this property won't be in sync with them.
IntegrationOwners
Gets which integrations authorized the interaction.
public IReadOnlyDictionary<ApplicationIntegrationType, ulong> IntegrationOwners { get; }
Property Value
IsDMInteraction
Gets whether or not this interaction was executed in a dm channel.
public bool IsDMInteraction { get; }
Property Value
IsValidToken
Gets whether or not the token used to respond to this interaction is valid.
public bool IsValidToken { get; }
Property Value
Permissions
Gets the permissions the app or bot has within the channel the interaction was sent from.
public GuildPermissions Permissions { get; }
Property Value
Token
Gets the continuation token for responding to the interaction.
public string Token { get; }
Property Value
Type
Gets the type of this IDiscordInteraction.
public InteractionType Type { get; }
Property Value
User
Gets the user who invoked the interaction.
public RestUser User { get; }
Property Value
Remarks
If this user is an RestGuildUser and APIOnRestInteractionCreation is set to false, Discord.Rest.RestGuildUser.Guild will return null
UserLocale
Gets the preferred locale of the invoking User.
public string UserLocale { get; }
Property Value
Remarks
This property returns null if the interaction is a REST ping interaction.
Version
Gets the version of the interaction, always 1.
public int Version { get; }
Property Value
Methods
Defer(bool, RequestOptions)
public abstract string Defer(bool ephemeral = false, RequestOptions options = null)
Parameters
ephemeral
booloptions
RequestOptions
Returns
DeleteOriginalResponseAsync(RequestOptions)
Deletes the original response to this interaction.
public Task DeleteOriginalResponseAsync(RequestOptions options = null)
Parameters
options
RequestOptionsThe request options for this async request.
Returns
- Task
A task that represents an asynchronous deletion operation.
FollowupAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)
Sends a followup message for this interaction.
public abstract Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
Parameters
text
stringThe text of the message to be sent.
embeds
Embed[]A array of embeds to send with this response. Max 10.
isTTS
booltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeral
booltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentions
AllowedMentionsThe allowed mentions for this response.
components
MessageComponentA MessageComponent to be sent with this response.
embed
EmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
options
RequestOptionsThe request options for this response.
poll
PollPropertiesA poll to send with the message.
Returns
- Task<RestFollowupMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
FollowupWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)
Sends a followup message for this interaction.
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(FileAttachment attachment, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
Parameters
attachment
FileAttachmentThe attachment containing the file and description.
text
stringThe text of the message to be sent.
embeds
Embed[]A array of embeds to send with this response. Max 10.
isTTS
booltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeral
booltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentions
AllowedMentionsThe allowed mentions for this response.
components
MessageComponentA MessageComponent to be sent with this response.
embed
EmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
options
RequestOptionsThe request options for this response.
poll
PollPropertiesA poll to send with the message.
Returns
- Task<RestFollowupMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
FollowupWithFileAsync(Stream, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)
Sends a followup message for this interaction.
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
Parameters
fileStream
StreamThe file to upload.
fileName
stringThe file name of the attachment.
text
stringThe text of the message to be sent.
embeds
Embed[]A array of embeds to send with this response. Max 10.
isTTS
booltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeral
booltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentions
AllowedMentionsThe allowed mentions for this response.
components
MessageComponentA MessageComponent to be sent with this response.
embed
EmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
options
RequestOptionsThe request options for this response.
poll
PollPropertiesA poll to send with the message.
Returns
- Task<RestFollowupMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
FollowupWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)
Sends a followup message for this interaction.
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string fileName = null, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
Parameters
filePath
stringThe file to upload.
fileName
stringThe file name of the attachment.
text
stringThe text of the message to be sent.
embeds
Embed[]A array of embeds to send with this response. Max 10.
isTTS
booltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeral
booltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentions
AllowedMentionsThe allowed mentions for this response.
components
MessageComponentA MessageComponent to be sent with this response.
embed
EmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
options
RequestOptionsThe request options for this response.
poll
PollPropertiesA poll to send with the message.
Returns
- Task<RestFollowupMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
FollowupWithFilesAsync(IEnumerable<FileAttachment>, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)
Sends a followup message for this interaction.
public abstract Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
Parameters
attachments
IEnumerable<FileAttachment>A collection of attachments to upload.
text
stringThe text of the message to be sent.
embeds
Embed[]A array of embeds to send with this response. Max 10.
isTTS
booltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeral
booltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentions
AllowedMentionsThe allowed mentions for this response.
components
MessageComponentA MessageComponent to be sent with this response.
embed
EmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
options
RequestOptionsThe request options for this response.
poll
PollPropertiesA poll to send with the message.
Returns
- Task<RestFollowupMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
GetChannelAsync(RequestOptions)
Gets the channel this interaction was executed in. Will be a DM channel if the interaction was executed in DM.
public Task<IRestMessageChannel> GetChannelAsync(RequestOptions options = null)
Parameters
options
RequestOptionsThe request options for this async request.
Returns
- Task<IRestMessageChannel>
A Rest channel to send messages to.
Remarks
Calling this method successfully will populate the Channel property. After this, further calls to this method will no longer call the API, and depend on the value set in Channel.
Exceptions
- InvalidOperationException
Thrown if no channel can be received.
GetGuildAsync(RequestOptions)
Gets the guild this interaction was executed in if applicable.
public Task<RestGuild> GetGuildAsync(RequestOptions options)
Parameters
options
RequestOptionsThe request options for this async request.
Returns
- Task<RestGuild>
The guild this interaction was executed in. null if the interaction was executed inside DM.
Remarks
Calling this method successfully will populate the Guild property. After this, further calls to this method will no longer call the API, and depend on the value set in Guild.
GetOriginalResponseAsync(RequestOptions)
Gets the original response for this interaction.
public Task<RestInteractionMessage> GetOriginalResponseAsync(RequestOptions options = null)
Parameters
options
RequestOptionsThe request options for this async request.
Returns
- Task<RestInteractionMessage>
A RestInteractionMessage that represents the initial response.
ModifyOriginalResponseAsync(Action<MessageProperties>, RequestOptions)
Edits original response for this interaction.
public Task<RestInteractionMessage> ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options = null)
Parameters
func
Action<MessageProperties>A delegate containing the properties to modify the message with.
options
RequestOptionsThe request options for this async request.
Returns
- Task<RestInteractionMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
Respond(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties)
public abstract string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null)
Parameters
text
stringembeds
Embed[]isTTS
boolephemeral
boolallowedMentions
AllowedMentionscomponents
MessageComponentembed
Embedoptions
RequestOptionspoll
PollProperties
Returns
RespondWithModal(Modal, RequestOptions)
public abstract string RespondWithModal(Modal modal, RequestOptions options = null)
Parameters
modal
Modaloptions
RequestOptions
Returns
RespondWithPremiumRequiredAsync(RequestOptions)
Responds to the interaction with an ephemeral message the invoking user, instructing them that whatever they tried to do requires the premium benefits of your app.
public Task RespondWithPremiumRequiredAsync(RequestOptions options = null)
Parameters
options
RequestOptions
Returns
- Task
A task that represents the asynchronous operation of responding to the interaction.