Search Results for

    Show / Hide Table of Contents

    Class RestInteraction

    Represents a REST-based interaction.

    Inheritance
    Object
    RestEntity<UInt64>
    RestInteraction
    RestAutocompleteInteraction
    RestCommandBase
    RestMessageComponent
    RestModal
    RestPingInteraction
    Implements
    IEntity<UInt64>
    IDiscordInteraction
    ISnowflakeEntity
    IEntity<UInt64>
    Inherited Members
    RestEntity<UInt64>.Id
    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 Source

    ApplicationId

    Declaration
    public ulong ApplicationId { get; }
    Property Value
    Type Description
    UInt64
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    ChannelId

    Declaration
    public ulong? ChannelId { get; }
    Property Value
    Type Description
    Nullable<UInt64>
    | Improve this Doc View Source

    CreatedAt

    Declaration
    public DateTimeOffset CreatedAt { get; }
    Property Value
    Type Description
    DateTimeOffset
    | Improve this Doc View Source

    Data

    Gets the data sent within this interaction.

    Declaration
    public IDiscordInteractionData Data { get; }
    Property Value
    Type Description
    IDiscordInteractionData
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    GuildId

    Declaration
    public ulong? GuildId { get; }
    Property Value
    Type Description
    Nullable<UInt64>
    | Improve this Doc View Source

    GuildLocale

    Declaration
    public string GuildLocale { get; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    HasResponded

    Declaration
    public bool HasResponded { get; protected set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    IsDMInteraction

    Declaration
    public bool IsDMInteraction { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    Token

    Declaration
    public string Token { get; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    Type

    Gets the type of this IDiscordInteraction.

    Declaration
    public InteractionType Type { get; }
    Property Value
    Type Description
    InteractionType
    | Improve this Doc View Source

    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

    | Improve this Doc View Source

    UserLocale

    Declaration
    public string UserLocale { get; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    Version

    Declaration
    public int Version { get; }
    Property Value
    Type Description
    Int32

    Methods

    | Improve this Doc View Source

    Defer(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
    | Improve this Doc View Source

    DeleteOriginalResponseAsync(RequestOptions)

    Declaration
    public Task DeleteOriginalResponseAsync(RequestOptions options = null)
    Parameters
    Type Name Description
    RequestOptions options
    Returns
    Type Description
    Task
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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 Source

    IDiscordInteraction.User

    Gets the user who invoked the interaction.

    Declaration
    IUser IDiscordInteraction.User { get; }
    Returns
    Type Description
    IUser

    Implements

    IEntity<TId>
    IDiscordInteraction
    ISnowflakeEntity
    IEntity<TId>

    Extension Methods

    RestExtensions.RespondWithModal<T>(RestInteraction, String, RequestOptions, Action<ModalBuilder>)

    Theme

    • Improve this Doc
    • View Source
    In This Article
    Back to top Discord.Net (c) 2015-2023 3.10.0