Class RestInteraction
Represents a REST-based interaction.
Inheritance
Inherited Members
Namespace: Discord.Rest
Assembly: Discord.Net.Rest.dll
Syntax
public abstract class RestInteraction : RestEntity<ulong>, IEntity<ulong>, IDiscordInteraction, ISnowflakeEntity, IEntity<ulong>
Properties
| Improve this Doc View SourceApplicationId
Declaration
public ulong ApplicationId { get; }
Property Value
Type | Description |
---|---|
UInt64 |
Channel
Gets the channel that this interaction was executed in.
Declaration
public IRestMessageChannel Channel { get; }
Property Value
Type | Description |
---|---|
IRestMessageChannel |
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
Declaration
public ulong? ChannelId { get; }
Property Value
Type | Description |
---|---|
Nullable<UInt64> |
CreatedAt
Declaration
public DateTimeOffset CreatedAt { get; }
Property Value
Type | Description |
---|---|
DateTimeOffset |
Data
Gets the data sent within this interaction.
Declaration
public IDiscordInteractionData Data { get; }
Property Value
Type | Description |
---|---|
IDiscordInteractionData |
Guild
Gets the guild this interaction was executed in if applicable.
Declaration
public RestGuild Guild { get; }
Property Value
Type | Description |
---|---|
RestGuild |
Remarks
This property will be null if APIOnRestInteractionCreation is set to false or if the interaction was not executed in a guild.
GuildId
Declaration
public ulong? GuildId { get; }
Property Value
Type | Description |
---|---|
Nullable<UInt64> |
GuildLocale
Declaration
public string GuildLocale { get; }
Property Value
Type | Description |
---|---|
String |
HasResponded
Declaration
public bool HasResponded { get; protected set; }
Property Value
Type | Description |
---|---|
Boolean |
IsDMInteraction
Declaration
public bool IsDMInteraction { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsValidToken
Gets whether or not the token used to respond to this interaction is valid.
Declaration
public bool IsValidToken { get; }
Property Value
Type | Description |
---|---|
Boolean |
Token
Declaration
public string Token { get; }
Property Value
Type | Description |
---|---|
String |
Type
Gets the type of this IDiscordInteraction.
Declaration
public InteractionType Type { get; }
Property Value
Type | Description |
---|---|
InteractionType |
User
Gets the user who invoked the interaction.
Declaration
public RestUser User { get; }
Property Value
Type | Description |
---|---|
RestUser |
Remarks
If this user is an RestGuildUser and APIOnRestInteractionCreation is set to false, Discord.Rest.RestGuildUser.Guild will return null
UserLocale
Declaration
public string UserLocale { get; }
Property Value
Type | Description |
---|---|
String |
Version
Declaration
public int Version { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceDefer(Boolean, RequestOptions)
Declaration
public abstract string Defer(bool ephemeral = false, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Boolean | ephemeral | |
RequestOptions | options |
Returns
Type | Description |
---|---|
String |
DeleteOriginalResponseAsync(RequestOptions)
Declaration
public Task DeleteOriginalResponseAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |
FollowupAsync(String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Sends a followup message for this interaction.
Declaration
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)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text of the message to be sent. |
Embed[] | embeds | A array of embeds to send with this response. Max 10. |
Boolean | isTTS | true if the message should be read out by a text-to-speech reader, otherwise false. |
Boolean | ephemeral | true if the response should be hidden to everyone besides the invoker of the command, otherwise false. |
AllowedMentions | allowedMentions | The allowed mentions for this response. |
MessageComponent | components | A MessageComponent to be sent with this response. |
Embed | embed | A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. |
RequestOptions | options | The request options for this response. |
Returns
Type | Description |
---|---|
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[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Sends a followup message for this interaction.
Declaration
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)
Parameters
Type | Name | Description |
---|---|---|
FileAttachment | attachment | The attachment containing the file and description. |
String | text | The text of the message to be sent. |
Embed[] | embeds | A array of embeds to send with this response. Max 10. |
Boolean | isTTS | true if the message should be read out by a text-to-speech reader, otherwise false. |
Boolean | ephemeral | true if the response should be hidden to everyone besides the invoker of the command, otherwise false. |
AllowedMentions | allowedMentions | The allowed mentions for this response. |
MessageComponent | components | A MessageComponent to be sent with this response. |
Embed | embed | A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. |
RequestOptions | options | The request options for this response. |
Returns
Type | Description |
---|---|
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[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Sends a followup message for this interaction.
Declaration
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)
Parameters
Type | Name | Description |
---|---|---|
Stream | fileStream | The file to upload. |
String | fileName | The file name of the attachment. |
String | text | The text of the message to be sent. |
Embed[] | embeds | A array of embeds to send with this response. Max 10. |
Boolean | isTTS | true if the message should be read out by a text-to-speech reader, otherwise false. |
Boolean | ephemeral | true if the response should be hidden to everyone besides the invoker of the command, otherwise false. |
AllowedMentions | allowedMentions | The allowed mentions for this response. |
MessageComponent | components | A MessageComponent to be sent with this response. |
Embed | embed | A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. |
RequestOptions | options | The request options for this response. |
Returns
Type | Description |
---|---|
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[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Sends a followup message for this interaction.
Declaration
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)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | The file to upload. |
String | fileName | The file name of the attachment. |
String | text | The text of the message to be sent. |
Embed[] | embeds | A array of embeds to send with this response. Max 10. |
Boolean | isTTS | true if the message should be read out by a text-to-speech reader, otherwise false. |
Boolean | ephemeral | true if the response should be hidden to everyone besides the invoker of the command, otherwise false. |
AllowedMentions | allowedMentions | The allowed mentions for this response. |
MessageComponent | components | A MessageComponent to be sent with this response. |
Embed | embed | A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. |
RequestOptions | options | The request options for this response. |
Returns
Type | Description |
---|---|
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[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Sends a followup message for this interaction.
Declaration
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)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<FileAttachment> | attachments | A collection of attachments to upload. |
String | text | The text of the message to be sent. |
Embed[] | embeds | A array of embeds to send with this response. Max 10. |
Boolean | isTTS | true if the message should be read out by a text-to-speech reader, otherwise false. |
Boolean | ephemeral | true if the response should be hidden to everyone besides the invoker of the command, otherwise false. |
AllowedMentions | allowedMentions | The allowed mentions for this response. |
MessageComponent | components | A MessageComponent to be sent with this response. |
Embed | embed | A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. |
RequestOptions | options | The request options for this response. |
Returns
Type | Description |
---|---|
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.
Declaration
public async Task<IRestMessageChannel> GetChannelAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The request options for this async request. |
Returns
Type | Description |
---|---|
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.
GetGuildAsync(RequestOptions)
Gets the guild this interaction was executed in if applicable.
Declaration
public async Task<RestGuild> GetGuildAsync(RequestOptions options)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The request options for this async request. |
Returns
Type | Description |
---|---|
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.
Declaration
public Task<RestInteractionMessage> GetOriginalResponseAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The request options for this async request. |
Returns
Type | Description |
---|---|
Task<RestInteractionMessage> | A RestInteractionMessage that represents the initial response. |
ModifyOriginalResponseAsync(Action<MessageProperties>, RequestOptions)
Edits original response for this interaction.
Declaration
public async Task<RestInteractionMessage> ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Action<MessageProperties> | func | A delegate containing the properties to modify the message with. |
RequestOptions | options | The request options for this async request. |
Returns
Type | Description |
---|---|
Task<RestInteractionMessage> | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
Respond(String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Declaration
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)
Parameters
Type | Name | Description |
---|---|---|
String | text | |
Embed[] | embeds | |
Boolean | isTTS | |
Boolean | ephemeral | |
AllowedMentions | allowedMentions | |
MessageComponent | components | |
Embed | embed | |
RequestOptions | options |
Returns
Type | Description |
---|---|
String |
RespondWithModal(Modal, RequestOptions)
Declaration
public abstract string RespondWithModal(Modal modal, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Modal | modal | |
RequestOptions | options |
Returns
Type | Description |
---|---|
String |
Explicit Interface Implementations
| Improve this Doc View SourceIDiscordInteraction.User
Gets the user who invoked the interaction.
Declaration
IUser IDiscordInteraction.User { get; }
Returns
Type | Description |
---|---|
IUser |