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
componentsIEnumerable<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
componentsIEnumerable<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
MaxCustomIdLength
The max length of a CustomId.
public const int MaxCustomIdLength = 100
Field Value
Properties
Count
Gets the number of components in the builder.
public int Count { get; }
Property Value
this[int]
Gets or sets the component at the specified index.
public IMessageComponentBuilder this[int index] { get; set; }
Parameters
indexintThe index of the component to get or set
Property Value
Methods
Add(IMessageComponent)
Adds a component to this ModalComponentBuilder.
public ModalComponentBuilder Add(IMessageComponent component)
Parameters
componentIMessageComponentThe component to add.
Returns
- ModalComponentBuilder
The current ModalComponentBuilder.
Add(IMessageComponentBuilder)
Adds a component to this ModalComponentBuilder.
public ModalComponentBuilder Add(IMessageComponentBuilder component)
Parameters
componentIMessageComponentBuilderThe 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
itemIMessageComponentBuilderThe object to locate in the ICollection<T>.
Returns
- bool
true if
itemis 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
arrayIMessageComponentBuilder[]The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.
arrayIndexintThe zero-based index in
arrayat which copying begins.
Exceptions
- ArgumentNullException
arrayis null.- ArgumentOutOfRangeException
arrayIndexis less than 0.- ArgumentException
The number of elements in the source ICollection<T> is greater than the available space from
arrayIndexto the end of the destinationarray.
FromComponents(params IEnumerable<IMessageComponent>)
Creates a new builder from the provided list of components.
public static ModalComponentBuilder FromComponents(params IEnumerable<IMessageComponent> components)
Parameters
componentsIEnumerable<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
itemIMessageComponentBuilderThe object to locate in the IList<T>.
Returns
- int
The index of
itemif 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
indexintThe zero-based index at which
itemshould be inserted.itemIMessageComponentBuilderThe object to insert into the IList<T>.
Exceptions
- ArgumentOutOfRangeException
indexis 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
itemIMessageComponentBuilderThe object to remove from the ICollection<T>.
Returns
- bool
true if
itemwas successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitemis 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
indexintThe zero-based index of the item to remove.
Exceptions
- ArgumentOutOfRangeException
indexis 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
componentsIEnumerable<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
labelstringThe label around the FileUploadComponentBuilder.
fileUploadFileUploadComponentBuilderThe file upload to add.
descriptionstringThe description around the FileUploadComponentBuilder.
labelIdint?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
labelstringThe label around the FileUploadComponentBuilder.
customIdstringThe custom id of the FileUploadComponentBuilder.
minValuesint?The min values of the FileUploadComponentBuilder.
maxValuesint?The max values of the FileUploadComponentBuilder.
isRequiredboolWhether the FileUploadComponentBuilder is required.
idint?The id of the FileUploadComponentBuilder.
descriptionstringThe description around the FileUploadComponentBuilder.
labelIdint?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
labelLabelBuilderThe 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
labelstringThe label of the LabelBuilder.
componentIMessageComponentBuilderThe component of the LabelBuilder.
descriptionstringThe description of the LabelBuilder.
idint?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
labelstringThe label around the SelectMenuBuilder.
menuSelectMenuBuilderThe menu to add.
descriptionstringThe description around the SelectMenuBuilder.
labelIdint?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
labelstringThe label around the SelectMenuBuilder.
customIdstringThe custom id of the SelectMenuBuilder.
optionsList<SelectMenuOptionBuilder>The options of the SelectMenuBuilder.
placeholderstringThe placeholder of the SelectMenuBuilder.
minValuesintThe min values of the SelectMenuBuilder.
maxValuesintThe max values of the SelectMenuBuilder.
requiredboolWhether the SelectMenuBuilder is required to be answered.
disabledboolWhether the SelectMenuBuilder is disabled.
typeComponentTypeThe type of the SelectMenuBuilder.
channelTypesChannelType[]The channel types of the SelectMenuBuilder.
defaultValuesSelectMenuDefaultValue[]The default values of the SelectMenuBuilder.
idint?The id of the SelectMenuBuilder.
descriptionstringThe description around the SelectMenuBuilder.
labelIdint?The id of the LabelBuilder wrapping the SelectMenuBuilder.
Returns
- ModalComponentBuilder
The current ModalComponentBuilder.
WithTextDisplay(TextDisplayBuilder)
Adds a TextDisplayBuilder to the current ModalComponentBuilder.
public ModalComponentBuilder WithTextDisplay(TextDisplayBuilder textDisplay)
Parameters
textDisplayTextDisplayBuilderThe 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
contentstringThe content of the TextDisplayBuilder.
idint?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
textTextInputBuilderThe 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
textTextInputBuilderThe text input to add.
rowintThe 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
labelstringThe label around the TextInputBuilder.
textInputTextInputBuilderThe text input to add.
descriptionstringThe description around the TextInputBuilder.
labelIdint?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
labelstringThe label around the TextInputBuilder.
customIdstringThe custom id of the TextInputBuilder.
styleTextInputStyleThe style of the TextInputBuilder.
placeholderstringThe placeholder of the TextInputBuilder.
minLengthint?The min length of the TextInputBuilder.
maxLengthint?The max length of the TextInputBuilder.
rowintDEPRECATED: The row to place the TextInputBuilder on.
requiredbool?Whether the TextInputBuilder is required.
valuestringThe value of the TextInputBuilder.
idint?The id of the TextInputBuilder.
descriptionstringThe description around the TextInputBuilder.
labelIdint?The id of the LabelBuilder wrapping the TextInputBuilder.
Returns
- ModalComponentBuilder
The current ModalComponentBuilder.