Skip to main content

Class SocketInteraction

Represents an Interaction received over the gateway.

Assembly: Discord.Net.WebSocket.dll​
View Source​
Declaration
public abstract class SocketInteraction : SocketEntity<ulong>, IDiscordInteraction, ISnowflakeEntity, IEntity<ulong>

Properties​

Channel​

The Discord.WebSocket.ISocketMessageChannel this interaction was used in.

View Source​
Declaration
public ISocketMessageChannel Channel { get; }

User​

The Discord.WebSocket.SocketUser who triggered this interaction.

View Source​
Declaration
public SocketUser User { get; }

Type​

The type of this interaction.

View Source​
Declaration
public InteractionType Type { get; }

Token​

The token used to respond to this interaction.

View Source​
Declaration
public string Token { get; }

Data​

The data sent with this interaction.

View Source​
Declaration
public IDiscordInteractionData Data { get; }

Version​

The version of this interaction.

View Source​
Declaration
public int Version { get; }

CreatedAt​

Gets when the snowflake was created.

View Source​
Declaration
public DateTimeOffset CreatedAt { get; }

HasResponded​

Gets whether or not this interaction has been responded to.

View Source​
Declaration
public abstract bool HasResponded { get; }

IsValidToken​

true if the token is valid for replying to, otherwise false.

View Source​
Declaration
public bool IsValidToken { get; }

Methods​

RespondAsync(String, Embed[], Boolean, Boolean, AllowedMentions, RequestOptions, MessageComponent, Embed)​

Responds to an Interaction with type Discord.InteractionResponseType.ChannelMessageWithSource.

View Source​
Declaration
public abstract Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
System.StringtextThe text of the message to be sent.
Discord.Embed[]embedsA array of embeds to send with this response. Max 10.
System.BooleanisTTStrue if the message should be read out by a text-to-speech reader, otherwise false.
System.Booleanephemeraltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
Discord.AllowedMentionsallowedMentionsThe allowed mentions for this response.
Discord.RequestOptionsoptionsThe request options for this response.
Discord.MessageComponentcomponentA Discord.MessageComponent to be sent with this response.
Discord.EmbedembedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.

FollowupAsync(String, Embed[], Boolean, Boolean, AllowedMentions, RequestOptions, MessageComponent, Embed)​

Sends a followup message for this interaction.

View Source​
Declaration
public abstract Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestFollowupMessage>: The sent message.

Parameters​
TypeNameDescription
System.StringtextThe text of the message to be sent.
Discord.Embed[]embedsA array of embeds to send with this response. Max 10.
System.BooleanisTTStrue if the message should be read out by a text-to-speech reader, otherwise false.
System.Booleanephemeraltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
Discord.AllowedMentionsallowedMentionsThe allowed mentions for this response.
Discord.RequestOptionsoptionsThe request options for this response.
Discord.MessageComponentcomponentA Discord.MessageComponent to be sent with this response.
Discord.EmbedembedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.

FollowupWithFileAsync(Stream, String, String, Embed[], Boolean, Boolean, AllowedMentions, RequestOptions, MessageComponent, Embed)​

Sends a followup message for this interaction.

View Source​
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, RequestOptions options = null, MessageComponent component = null, Embed embed = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestFollowupMessage>: The sent message.

Parameters​
TypeNameDescription
System.IO.StreamfileStreamThe file to upload.
System.StringfileNameThe file name of the attachment.
System.StringtextThe text of the message to be sent.
Discord.Embed[]embedsA array of embeds to send with this response. Max 10.
System.BooleanisTTStrue if the message should be read out by a text-to-speech reader, otherwise false.
System.Booleanephemeraltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
Discord.AllowedMentionsallowedMentionsThe allowed mentions for this response.
Discord.RequestOptionsoptionsThe request options for this response.
Discord.MessageComponentcomponentA Discord.MessageComponent to be sent with this response.
Discord.EmbedembedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.

FollowupWithFileAsync(String, String, String, Embed[], Boolean, Boolean, AllowedMentions, RequestOptions, MessageComponent, Embed)​

Sends a followup message for this interaction.

View Source​
Declaration
public abstract Task<RestFollowupMessage> FollowupWithFileAsync(string filePath, string text = null, string fileName = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestFollowupMessage>: The sent message.

Parameters​
TypeNameDescription
System.StringfilePathThe file to upload.
System.StringtextThe text of the message to be sent.
System.StringfileNameThe file name of the attachment.
Discord.Embed[]embedsA array of embeds to send with this response. Max 10.
System.BooleanisTTStrue if the message should be read out by a text-to-speech reader, otherwise false.
System.Booleanephemeraltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
Discord.AllowedMentionsallowedMentionsThe allowed mentions for this response.
Discord.RequestOptionsoptionsThe request options for this response.
Discord.MessageComponentcomponentA Discord.MessageComponent to be sent with this response.
Discord.EmbedembedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.

GetOriginalResponseAsync(RequestOptions)​

Gets the original response for this interaction.

View Source​
Declaration
public Task<RestInteractionMessage> GetOriginalResponseAsync(RequestOptions options = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestInteractionMessage>: A Discord.Rest.RestInteractionMessage that represents the initial response.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe request options for this async request.

ModifyOriginalResponseAsync(Action<MessageProperties>, RequestOptions)​

Edits original response for this interaction.

View Source​
Declaration
public async Task<RestInteractionMessage> ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options = null)
Returns​

System.Threading.Tasks.Task<Discord.Rest.RestInteractionMessage>: A Discord.Rest.RestInteractionMessage that represents the initial response.

Parameters​
TypeNameDescription
System.Action<Discord.MessageProperties>funcA delegate containing the properties to modify the message with.
Discord.RequestOptionsoptionsThe request options for this async request.

DeferAsync(Boolean, RequestOptions)​

Acknowledges this interaction.

View Source​
Declaration
public abstract Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
Returns​

System.Threading.Tasks.Task: A task that represents the asynchronous operation of acknowledging the interaction.

Parameters​
TypeNameDescription
System.Booleanephemeraltrue to send this message ephemerally, otherwise false.
Discord.RequestOptionsoptionsThe request options for this async request.

IDiscordInteraction.FollowupAsync(String, Embed[], Boolean, Boolean, AllowedMentions, RequestOptions, MessageComponent, Embed)​

Sends a followup message for this interaction.

View Source​
Declaration
async Task<IUserMessage> IDiscordInteraction.FollowupAsync(string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, RequestOptions options, MessageComponent component, Embed embed)
Returns​

System.Threading.Tasks.Task<Discord.IUserMessage>: The sent message.

Parameters​
TypeNameDescription
System.StringtextThe text of the message to be sent.
Discord.Embed[]embedsA array of embeds to send with this response. Max 10.
System.BooleanisTTStrue if the message should be read out by a text-to-speech reader, otherwise false.
System.Booleanephemeraltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
Discord.AllowedMentionsallowedMentionsThe allowed mentions for this response.
Discord.RequestOptionsoptionsThe request options for this response.
Discord.MessageComponentcomponentA Discord.MessageComponent to be sent with this response.
Discord.EmbedembedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.

IDiscordInteraction.GetOriginalResponseAsync(RequestOptions)​

Gets the original response for this interaction.

View Source​
Declaration
async Task<IUserMessage> IDiscordInteraction.GetOriginalResponseAsync(RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IUserMessage>: A Discord.IUserMessage that represents the initial response.

Parameters​
TypeNameDescription
Discord.RequestOptionsoptionsThe request options for this async request.

IDiscordInteraction.ModifyOriginalResponseAsync(Action<MessageProperties>, RequestOptions)​

Edits original response for this interaction.

View Source​
Declaration
async Task<IUserMessage> IDiscordInteraction.ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options)
Returns​

System.Threading.Tasks.Task<Discord.IUserMessage>: A Discord.IUserMessage that represents the initial response.

Parameters​
TypeNameDescription
System.Action<Discord.MessageProperties>funcA delegate containing the properties to modify the message with.
Discord.RequestOptionsoptionsThe request options for this async request.

Implements​