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()

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.

Exceptions

ArgumentException

Only TextInputComponents are allowed.

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(List<IMessageComponent>, int)

Adds multiple components to the current builder.

public ModalBuilder AddComponents(List<IMessageComponent> components, int row)

Parameters

components List<IMessageComponent>

The components to add.

row int

Returns

ModalBuilder

The current builder

AddTextInput(TextInputBuilder, int)

Adds a component to the current builder.

public ModalBuilder AddTextInput(TextInputBuilder component, int row = 0)

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)

Adds a TextInputBuilder to the current builder.

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

Parameters

label string

The input's label.

customId string

The input's custom id.

style TextInputStyle

The input's style.

placeholder string

The input's placeholder text.

minLength int?

The input's minimum length.

maxLength int?

The input's maximum length.

required bool?
value string

Returns

ModalBuilder

The current builder.

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<TMessageComponent>(string)

Gets a TMessageComponent by the specified customId.

public TMessageComponent GetComponent<TMessageComponent>(string customId) where TMessageComponent : class, IMessageComponent

Parameters

customId string

The CustomId of the component to get.

Returns

TMessageComponent

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

Type Parameters

TMessageComponent

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.