Table of Contents

Class ModalBuilder

Namespace
Discord
Assembly
Discord.Net.Core.dll

Represents a builder for creating a Modal.

public class ModalBuilder
Inheritance
ModalBuilder
Inherited Members

Constructors

ModalBuilder()

Creates a new and empty ModalBuilder.

public ModalBuilder()

ModalBuilder(string, string, ModalComponentBuilder)

Creates a new instance of the ModalBuilder.

public ModalBuilder(string title, string customId, ModalComponentBuilder components = null)

Parameters

title string

The modal's title.

customId string

The modal's customId.

components ModalComponentBuilder

The modal's components.

ModalBuilder(string, string, params IEnumerable<IMessageComponentBuilder>)

Creates a new instance of the ModalBuilder.

public ModalBuilder(string title, string customId, params IEnumerable<IMessageComponentBuilder> components)

Parameters

title string

The modal's title.

customId string

The modal's customId.

components IEnumerable<IMessageComponentBuilder>

The modal's components.

ModalBuilder(string, string, params IEnumerable<IMessageComponent>)

Creates a new instance of the ModalBuilder.

public ModalBuilder(string title, string customId, params IEnumerable<IMessageComponent> components)

Parameters

title string

The modal's title.

customId string

The modal's customId.

components IEnumerable<IMessageComponent>

The modal's components.

Properties

Components

Gets or sets the components of the current modal.

public ModalComponentBuilder Components { get; set; }

Property Value

ModalComponentBuilder

CustomId

Gets or sets the custom ID of the current modal.

public string CustomId { get; set; }

Property Value

string

Title

Gets or sets the title of the current modal.

public string Title { get; set; }

Property Value

string

Methods

AddComponents(params IEnumerable<IMessageComponentBuilder>)

Adds multiple components to the current builder.

public ModalBuilder AddComponents(params IEnumerable<IMessageComponentBuilder> components)

Parameters

components IEnumerable<IMessageComponentBuilder>

The components to add.

Returns

ModalBuilder

The current builder

AddComponents(List<IMessageComponent>, int)

Adds multiple components to the current builder.

[Obsolete("Modal components no longer have rows", false)]
public ModalBuilder AddComponents(List<IMessageComponent> components, int row)

Parameters

components List<IMessageComponent>

The components to add.

row int

Returns

ModalBuilder

The current builder

AddFileUpload(string, FileUploadComponentBuilder, string, int?)

Constructs and adds a LabelBuilder with the provided FileUploadComponentBuilder to the current ModalComponentBuilder.

public ModalBuilder AddFileUpload(string label, FileUploadComponentBuilder fileUpload, string description = null, int? labelId = null)

Parameters

label string

The label around the FileUploadComponentBuilder.

fileUpload FileUploadComponentBuilder

The file upload to add.

description string

The description around the FileUploadComponentBuilder.

labelId int?

The id of the LabelBuilder wrapping the FileUploadComponentBuilder.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddFileUpload(string, string, int?, int?, bool, int?, string, int?)

Constructs and adds a LabelBuilder with a FileUploadComponentBuilder to the current ModalComponentBuilder.

public ModalBuilder AddFileUpload(string label, string customId, int? minValues = null, int? maxValues = null, bool isRequired = true, int? id = null, string description = null, int? labelId = null)

Parameters

label string

The label around the FileUploadComponentBuilder.

customId string

The custom id of the FileUploadComponentBuilder.

minValues int?

The min values of the FileUploadComponentBuilder.

maxValues int?

The max values of the FileUploadComponentBuilder.

isRequired bool

Whether the FileUploadComponentBuilder is required.

id int?

The id of the FileUploadComponentBuilder.

description string

The description around the FileUploadComponentBuilder.

labelId int?

The id of the LabelBuilder wrapping the FileUploadComponentBuilder.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddLabel(LabelBuilder)

Adds a LabelBuilder to the current ModalComponentBuilder.

public ModalBuilder AddLabel(LabelBuilder label)

Parameters

label LabelBuilder

The LabelBuilder to add.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddLabel(string, IMessageComponentBuilder, string, int?)

Constructs and adds a LabelBuilder to the current ModalComponentBuilder.

public ModalBuilder AddLabel(string label, IMessageComponentBuilder component, string description = null, int? id = null)

Parameters

label string

The label of the LabelBuilder.

component IMessageComponentBuilder

The component of the LabelBuilder.

description string

The description of the LabelBuilder.

id int?

The id of the LabelBuilder.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddSelectMenu(string, SelectMenuBuilder, string, int?)

Constructs and adds a LabelBuilder with the provided SelectMenuBuilder to the current ModalComponentBuilder.

public ModalBuilder AddSelectMenu(string label, SelectMenuBuilder menu, string description = null, int? labelId = null)

Parameters

label string

The label around the SelectMenuBuilder.

menu SelectMenuBuilder

The menu to add.

description string

The description around the SelectMenuBuilder.

labelId int?

The id of the LabelBuilder wrapping the SelectMenuBuilder.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddSelectMenu(string, string, List<SelectMenuOptionBuilder>, string, int, int, bool, bool, ComponentType, ChannelType[], SelectMenuDefaultValue[], int?, string, int?)

Constructs and adds a LabelBuilder containing a SelectMenuBuilder to the current ModalComponentBuilder.

public ModalBuilder AddSelectMenu(string label, string customId, List<SelectMenuOptionBuilder> options = null, string placeholder = null, int minValues = 1, int maxValues = 1, bool required = true, bool disabled = false, ComponentType type = ComponentType.SelectMenu, ChannelType[] channelTypes = null, SelectMenuDefaultValue[] defaultValues = null, int? id = null, string description = null, int? labelId = null)

Parameters

label string

The label around the SelectMenuBuilder.

customId string

The custom id of the SelectMenuBuilder.

options List<SelectMenuOptionBuilder>

The options of the SelectMenuBuilder.

placeholder string

The placeholder of the SelectMenuBuilder.

minValues int

The min values of the SelectMenuBuilder.

maxValues int

The max values of the SelectMenuBuilder.

required bool

Whether the SelectMenuBuilder is required to be answered.

disabled bool

Whether the SelectMenuBuilder is disabled.

type ComponentType

The type of the SelectMenuBuilder.

channelTypes ChannelType[]

The channel types of the SelectMenuBuilder.

defaultValues SelectMenuDefaultValue[]

The default values of the SelectMenuBuilder.

id int?

The id of the SelectMenuBuilder.

description string

The description around the SelectMenuBuilder.

labelId int?

The id of the LabelBuilder wrapping the SelectMenuBuilder.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddTextDisplay(TextDisplayBuilder)

public ModalBuilder AddTextDisplay(TextDisplayBuilder textDisplay)

Parameters

textDisplay TextDisplayBuilder

The TextDisplayBuilder to add.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddTextDisplay(string, int?)

Constructs and adds a TextDisplayBuilder to the current ModalComponentBuilder.

public ModalBuilder AddTextDisplay(string content, int? id = null)

Parameters

content string

The content of the TextDisplayBuilder.

id int?

The id of the TextDisplayBuilder.

Returns

ModalBuilder

The current ModalComponentBuilder.

AddTextInput(TextInputBuilder, int)

Adds a component to the current builder.

[Obsolete("Modal components no longer have rows", false)]
public ModalBuilder AddTextInput(TextInputBuilder component, int row)

Parameters

component TextInputBuilder

The component to add.

row int

The row to add the text input.

Returns

ModalBuilder

The current builder.

AddTextInput(string, string, TextInputStyle, string, int?, int?, bool?, string, int?, string, int?)

Constructs and adds a LabelBuilder with a TextInputBuilder to the current ModalComponentBuilder.

public ModalBuilder AddTextInput(string label, string customId, TextInputStyle style = TextInputStyle.Short, string placeholder = null, int? minLength = null, int? maxLength = null, bool? required = null, string value = null, int? id = null, string description = null, int? labelId = null)

Parameters

label string

The label around the TextInputBuilder.

customId string

The custom id of the TextInputBuilder.

style TextInputStyle

The style of the TextInputBuilder.

placeholder string

The placeholder of the TextInputBuilder.

minLength int?

The min length of the TextInputBuilder.

maxLength int?

The max length of the TextInputBuilder.

required bool?

Whether the TextInputBuilder is required.

value string

The value of the TextInputBuilder.

id int?

The id of the TextInputBuilder.

description string

The description around the TextInputBuilder.

labelId int?

The id of the LabelBuilder wrapping the TextInputBuilder.

Returns

ModalBuilder

The current ModalComponentBuilder.

Build()

Builds this builder into a Modal.

public Modal Build()

Returns

Modal

A Modal with the same values as this builder.

Exceptions

ArgumentException

Modals must have a custom ID.

ArgumentException

Modals must have a title.

ArgumentException

Only components of type TextInputComponent are allowed.

GetComponent(string)

Gets a IInteractableComponentBuilder by the specified customId.

public IInteractableComponentBuilder GetComponent(string customId)

Parameters

customId string

The CustomId of the component to get.

Returns

IInteractableComponentBuilder

The component that was found, null otherwise.

GetComponent<TMessageComponentBuilder>(string)

Gets a TMessageComponentBuilder by the specified customId.

public TMessageComponentBuilder GetComponent<TMessageComponentBuilder>(string customId) where TMessageComponentBuilder : class, IInteractableComponentBuilder

Parameters

customId string

The CustomId of the component to get.

Returns

TMessageComponentBuilder

The component of type TMessageComponentBuilder that was found, null otherwise.

Type Parameters

TMessageComponentBuilder

The type of the component to get.

RemoveComponent(string)

Removes a component from this builder by the specified customId.

public ModalBuilder RemoveComponent(string customId)

Parameters

customId string

The CustomId of the component to remove.

Returns

ModalBuilder

The current builder.

RemoveComponentsOfType(ComponentType)

Removes all components of the given type from this builder.

public ModalBuilder RemoveComponentsOfType(ComponentType type)

Parameters

type ComponentType

The ComponentType to remove.

Returns

ModalBuilder

The current builder.

UpdateTextInput(string, Action<TextInputBuilder>)

Updates a TextInputComponent by the specified customId.

public ModalBuilder UpdateTextInput(string customId, Action<TextInputBuilder> updateTextInput)

Parameters

customId string

The CustomId of the input to update.

updateTextInput Action<TextInputBuilder>

An action that configures the updated text input.

Returns

ModalBuilder

The current builder.

Exceptions

ArgumentException

Thrown when the TextInputComponent to be updated was not found.

UpdateTextInput(string, object)

Updates the value of a TextInputComponent by the specified customId.

public ModalBuilder UpdateTextInput(string customId, object value)

Parameters

customId string

The CustomId of the input to update.

value object

The new value to put.

Returns

ModalBuilder

The current builder.

WithCustomId(string)

Sets the custom id of the current modal.

public ModalBuilder WithCustomId(string customId)

Parameters

customId string

The value to set the custom id to.

Returns

ModalBuilder

The current builder.

WithTitle(string)

Sets the title of the current modal.

public ModalBuilder WithTitle(string title)

Parameters

title string

The value to set the title to.

Returns

ModalBuilder

The current builder.