Table of Contents

Class ModalComponentBuilder

Namespace
Discord
Assembly
Discord.Net.Core.dll

Represents a builder for creating a ModalComponent.

public class ModalComponentBuilder : IList<IMessageComponentBuilder>, ICollection<IMessageComponentBuilder>, IEnumerable<IMessageComponentBuilder>, IEnumerable
Inheritance
ModalComponentBuilder
Implements
Inherited Members
Extension Methods

Constructors

ModalComponentBuilder()

Constructs an empty ModalComponentBuilder.

public ModalComponentBuilder()

ModalComponentBuilder(params IEnumerable<IMessageComponentBuilder>)

Constructs a ModalComponentBuilder with the provided IMessageComponentBuilders.

public ModalComponentBuilder(params IEnumerable<IMessageComponentBuilder> components)

Parameters

components IEnumerable<IMessageComponentBuilder>

The components to add to this ModalComponentBuilder

ModalComponentBuilder(params IEnumerable<IMessageComponent>)

Constructs a ModalComponentBuilder with the provided IMessageComponents.

public ModalComponentBuilder(params IEnumerable<IMessageComponent> components)

Parameters

components IEnumerable<IMessageComponent>

The components to add to this ModalComponentBuilder

Fields

MaxActionRowCount

The max amount of rows a ModalComponent can have.

[Obsolete("Modal components no longer support action rows", true)]
public const int MaxActionRowCount = 5

Field Value

int

MaxCustomIdLength

The max length of a CustomId.

public const int MaxCustomIdLength = 100

Field Value

int

Properties

Count

Gets the number of components in the builder.

public int Count { get; }

Property Value

int

this[int]

Gets or sets the component at the specified index.

public IMessageComponentBuilder this[int index] { get; set; }

Parameters

index int

The index of the component to get or set

Property Value

IMessageComponentBuilder

Methods

Add(IMessageComponent)

Adds a component to this ModalComponentBuilder.

public ModalComponentBuilder Add(IMessageComponent component)

Parameters

component IMessageComponent

The component to add.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

Add(IMessageComponentBuilder)

Adds a component to this ModalComponentBuilder.

public ModalComponentBuilder Add(IMessageComponentBuilder component)

Parameters

component IMessageComponentBuilder

The component to add.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

Build()

Get a ModalComponent representing the builder.

public ModalComponent Build()

Returns

ModalComponent

A ModalComponent representing the builder.

Clear()

Removes all items from the ICollection<T>.

public void Clear()

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Contains(IMessageComponentBuilder)

Determines whether the ICollection<T> contains a specific value.

public bool Contains(IMessageComponentBuilder item)

Parameters

item IMessageComponentBuilder

The object to locate in the ICollection<T>.

Returns

bool

true if item is found in the ICollection<T>; otherwise, false.

CopyTo(IMessageComponentBuilder[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

public void CopyTo(IMessageComponentBuilder[] array, int arrayIndex)

Parameters

array IMessageComponentBuilder[]

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

FromComponents(params IEnumerable<IMessageComponent>)

Creates a new builder from the provided list of components.

public static ModalComponentBuilder FromComponents(params IEnumerable<IMessageComponent> components)

Parameters

components IEnumerable<IMessageComponent>

The components to create the builder from.

Returns

ModalComponentBuilder

The newly created builder.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<IMessageComponentBuilder> GetEnumerator()

Returns

IEnumerator<IMessageComponentBuilder>

An enumerator that can be used to iterate through the collection.

IndexOf(IMessageComponentBuilder)

Determines the index of a specific item in the IList<T>.

public int IndexOf(IMessageComponentBuilder item)

Parameters

item IMessageComponentBuilder

The object to locate in the IList<T>.

Returns

int

The index of item if found in the list; otherwise, -1.

Insert(int, IMessageComponentBuilder)

Inserts an item to the IList<T> at the specified index.

public void Insert(int index, IMessageComponentBuilder item)

Parameters

index int

The zero-based index at which item should be inserted.

item IMessageComponentBuilder

The object to insert into the IList<T>.

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the IList<T>.

NotSupportedException

The IList<T> is read-only.

Remove(IMessageComponentBuilder)

Removes the first occurrence of a specific object from the ICollection<T>.

public bool Remove(IMessageComponentBuilder item)

Parameters

item IMessageComponentBuilder

The object to remove from the ICollection<T>.

Returns

bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

RemoveAt(int)

Removes the IList<T> item at the specified index.

public void RemoveAt(int index)

Parameters

index int

The zero-based index of the item to remove.

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the IList<T>.

NotSupportedException

The IList<T> is read-only.

With(params IEnumerable<IMessageComponentBuilder>)

Sets the components in this builder to the provided components

public ModalComponentBuilder With(params IEnumerable<IMessageComponentBuilder> components)

Parameters

components IEnumerable<IMessageComponentBuilder>

The components to set this builder to.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

WithFileUpload(string, FileUploadComponentBuilder, string, int?)

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

public ModalComponentBuilder WithFileUpload(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

ModalComponentBuilder

The current ModalComponentBuilder.

WithFileUpload(string, string, int?, int?, bool, int?, string, int?)

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

public ModalComponentBuilder WithFileUpload(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

ModalComponentBuilder

The current ModalComponentBuilder.

WithLabel(LabelBuilder)

Adds a LabelBuilder to the current ModalComponentBuilder.

public ModalComponentBuilder WithLabel(LabelBuilder label)

Parameters

label LabelBuilder

The LabelBuilder to add.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

WithLabel(string, IMessageComponentBuilder, string, int?)

Constructs and adds a LabelBuilder to the current ModalComponentBuilder.

public ModalComponentBuilder WithLabel(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

ModalComponentBuilder

The current ModalComponentBuilder.

WithSelectMenu(string, SelectMenuBuilder, string, int?)

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

public ModalComponentBuilder WithSelectMenu(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

ModalComponentBuilder

The current ModalComponentBuilder.

WithSelectMenu(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 ModalComponentBuilder WithSelectMenu(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

ModalComponentBuilder

The current ModalComponentBuilder.

WithTextDisplay(TextDisplayBuilder)

public ModalComponentBuilder WithTextDisplay(TextDisplayBuilder textDisplay)

Parameters

textDisplay TextDisplayBuilder

The TextDisplayBuilder to add.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

WithTextDisplay(string, int?)

Constructs and adds a TextDisplayBuilder to the current ModalComponentBuilder.

public ModalComponentBuilder WithTextDisplay(string content, int? id = null)

Parameters

content string

The content of the TextDisplayBuilder.

id int?

The id of the TextDisplayBuilder.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

WithTextInput(TextInputBuilder)

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

[Obsolete("text components must be wrapped in a label", false)]
public ModalComponentBuilder WithTextInput(TextInputBuilder text)

Parameters

text TextInputBuilder

The text input to add.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

WithTextInput(TextInputBuilder, int)

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

[Obsolete("Modal components no longer have rows", false)]
public ModalComponentBuilder WithTextInput(TextInputBuilder text, int row)

Parameters

text TextInputBuilder

The text input to add.

row int

The row to add the text input to.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

WithTextInput(string, TextInputBuilder, string, int?)

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

public ModalComponentBuilder WithTextInput(string label, TextInputBuilder textInput, string description = null, int? labelId = null)

Parameters

label string

The label around the TextInputBuilder.

textInput TextInputBuilder

The text input to add.

description string

The description around the TextInputBuilder.

labelId int?

The id of the LabelBuilder wrapping the TextInputBuilder.

Returns

ModalComponentBuilder

The current ModalComponentBuilder.

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

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

public ModalComponentBuilder WithTextInput(string label, string customId, TextInputStyle style = TextInputStyle.Short, string placeholder = null, int? minLength = null, int? maxLength = null, int row = 0, 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.

row int

DEPRECATED: The row to place the TextInputBuilder on.

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

ModalComponentBuilder

The current ModalComponentBuilder.