Table of Contents

Class RestModal

Namespace
Discord.Rest
Assembly
Discord.Net.Rest.dll

Represents a user submitted Modal.

public class RestModal : RestInteraction, IModalInteraction, IDiscordInteraction, ISnowflakeEntity, IEntity<ulong>
Inheritance
RestModal
Implements
Inherited Members
Extension Methods

Properties

Data

Gets the data received with this interaction; contains the clicked button.

public RestModalData Data { get; set; }

Property Value

RestModalData

Message

Gets the message the modal originates from.

public RestUserMessage Message { get; }

Property Value

RestUserMessage

Remarks

This property is only populated if the modal was created from a message component.

Methods

Defer(bool, RequestOptions)

Acknowledges this interaction with the DeferredUpdateMessage if the modal was created in a response to a message component interaction, DeferredChannelMessageWithSource otherwise.

public override string Defer(bool ephemeral = false, RequestOptions options = null)

Parameters

ephemeral bool
options RequestOptions

Returns

string

A string that contains json to write back to the incoming http request.

DeferLoading(bool, RequestOptions)

Defers an interaction and responds with type 5 (DeferredChannelMessageWithSource)

public string DeferLoading(bool ephemeral = false, RequestOptions options = null)

Parameters

ephemeral bool

true to send this message ephemerally, otherwise false.

options RequestOptions

The request options for this async request.

Returns

string

A string that contains json to write back to the incoming http request.

FollowupAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions)

Sends a followup message for this interaction.

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

Parameters

text string

The text of the message to be sent.

embeds Embed[]

A array of embeds to send with this response. Max 10.

isTTS bool

true if the message should be read out by a text-to-speech reader, otherwise false.

ephemeral bool

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.

component MessageComponent

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.

options RequestOptions

The request options for this response.

Returns

Task<RestFollowupMessage>

The sent message.

FollowupWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions)

Sends a followup message for this interaction.

public override 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

attachment FileAttachment

The attachment containing the file and description.

text string

The text of the message to be sent.

embeds Embed[]

A array of embeds to send with this response. Max 10.

isTTS bool

true if the message should be read out by a text-to-speech reader, otherwise false.

ephemeral bool

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.

components MessageComponent

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.

options RequestOptions

The request options for this response.

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)

Sends a followup message for this interaction.

public override Task<RestFollowupMessage> FollowupWithFileAsync(Stream fileStream, string fileName, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent component = null, Embed embed = null, RequestOptions options = null)

Parameters

fileStream Stream

The file to upload.

fileName string

The file name of the attachment.

text string

The text of the message to be sent.

embeds Embed[]

A array of embeds to send with this response. Max 10.

isTTS bool

true if the message should be read out by a text-to-speech reader, otherwise false.

ephemeral bool

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.

component MessageComponent

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.

options RequestOptions

The request options for this response.

Returns

Task<RestFollowupMessage>

The sent message.

FollowupWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions)

Sends a followup message for this interaction.

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

Parameters

filePath string

The file to upload.

text string

The text of the message to be sent.

fileName string

The file name of the attachment.

embeds Embed[]

A array of embeds to send with this response. Max 10.

isTTS bool

true if the message should be read out by a text-to-speech reader, otherwise false.

ephemeral bool

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.

component MessageComponent

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.

options RequestOptions

The request options for this response.

Returns

Task<RestFollowupMessage>

The sent message.

FollowupWithFilesAsync(IEnumerable<FileAttachment>, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions)

Sends a followup message for this interaction.

public override 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

attachments IEnumerable<FileAttachment>

A collection of attachments to upload.

text string

The text of the message to be sent.

embeds Embed[]

A array of embeds to send with this response. Max 10.

isTTS bool

true if the message should be read out by a text-to-speech reader, otherwise false.

ephemeral bool

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.

components MessageComponent

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.

options RequestOptions

The request options for this response.

Returns

Task<RestFollowupMessage>

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)

Responds to an Interaction with type ChannelMessageWithSource.

public override string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent component = null, Embed embed = null, RequestOptions options = null)

Parameters

text string

The text of the message to be sent.

embeds Embed[]

A array of embeds to send with this response. Max 10.

isTTS bool

true if the message should be read out by a text-to-speech reader, otherwise false.

ephemeral bool

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.

component MessageComponent

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.

options RequestOptions

The request options for this response.

Returns

string

A string that contains json to write back to the incoming http request.

Exceptions

ArgumentOutOfRangeException

Message content is too long, length must be less or equal to MaxMessageSize.

InvalidOperationException

The parameters provided were invalid or the token was invalid.

RespondWithModal(Modal, RequestOptions)

public override string RespondWithModal(Modal modal, RequestOptions requestOptions = null)

Parameters

modal Modal
requestOptions RequestOptions

Returns

string

UpdateAsync(Action<MessageProperties>, RequestOptions)

Updates the message which this modal originates from with the type UpdateMessage

public Task UpdateAsync(Action<MessageProperties> func, RequestOptions options = null)

Parameters

func Action<MessageProperties>

A delegate containing the properties to modify the message with.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous operation of updating the message.

Remarks

This method can be used only if the modal was created from a message component.