Class SocketInteraction
Represents an Interaction received over the gateway.
Inheritance
Inherited Members
Namespace: Discord.WebSocket
Assembly: Discord.Net.WebSocket.dll
Syntax
public abstract class SocketInteraction : SocketEntity<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 ISocketMessageChannel this interaction was used in.
Declaration
public ISocketMessageChannel Channel { get; }
Property Value
Type | Description |
---|---|
ISocketMessageChannel |
Remarks
If the channel isn't cached, the bot scope isn't used, or the bot doesn't have access to it then this property will be null.
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 |
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 abstract bool HasResponded { get; }
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 SocketUser who triggered this interaction.
Declaration
public SocketUser User { get; }
Property Value
Type | Description |
---|---|
SocketUser |
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 SourceDeferAsync(Boolean, RequestOptions)
Acknowledges this interaction.
Declaration
public abstract Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Boolean | ephemeral | true to send this message ephemerally, otherwise false. |
RequestOptions | options | The request options for this async request. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation of acknowledging the interaction. |
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> | The sent message. |
FollowupWithFileAsync(FileAttachment, String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Sends a followup message for this interaction.
Declaration
public 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 async 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> | The sent message. |
FollowupWithFileAsync(String, String, String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Sends a followup message for this interaction.
Declaration
public async 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> | 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)
Attempts to get the channel this interaction was executed in.
Declaration
public async ValueTask<IMessageChannel> GetChannelAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The request options for this async request. |
Returns
Type | Description |
---|---|
ValueTask<IMessageChannel> | A task that represents the asynchronous operation of fetching the channel. |
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 RestInteractionMessage that represents the initial response. |
RespondAsync(String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Responds to an Interaction with type ChannelMessageWithSource.
Declaration
public abstract Task RespondAsync(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 |
RespondWithFileAsync(FileAttachment, String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Responds to this interaction with a file attachment.
Declaration
public Task RespondWithFileAsync(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 | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
RespondWithFileAsync(Stream, String, String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Responds to this interaction with a file attachment.
Declaration
public async Task RespondWithFileAsync(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 | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
RespondWithFileAsync(String, String, String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Responds to this interaction with a file attachment.
Declaration
public async Task RespondWithFileAsync(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 | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
RespondWithFilesAsync(IEnumerable<FileAttachment>, String, Embed[], Boolean, Boolean, AllowedMentions, MessageComponent, Embed, RequestOptions)
Responds to this interaction with a collection of file attachments.
Declaration
public abstract Task RespondWithFilesAsync(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 | A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. |
RespondWithModalAsync(Modal, RequestOptions)
Responds to this interaction with a Modal.
Declaration
public abstract Task RespondWithModalAsync(Modal modal, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Modal | modal | The Modal to respond with. |
RequestOptions | options | The request options for this async request. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation of responding to the interaction. |
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 |