Class ModalComponentBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a builder for creating a ModalComponent.
public class ModalComponentBuilder
- Inheritance
-
ModalComponentBuilder
- Inherited Members
Fields
MaxActionRowCount
The max amount of rows a ModalComponent can have.
public const int MaxActionRowCount = 5
Field Value
MaxCustomIdLength
The max length of a CustomId.
public const int MaxCustomIdLength = 100
Field Value
Properties
ActionRows
Gets or sets the Action Rows for this Component Builder.
public List<ActionRowBuilder> ActionRows { get; set; }
Property Value
Exceptions
- ArgumentNullException
ActionRows cannot be null.
- ArgumentException
ActionRows count exceeds MaxActionRowCount.
Methods
Build()
Get a ModalComponent representing the builder.
public ModalComponent Build()
Returns
- ModalComponent
A ModalComponent representing the builder.
FromComponents(IReadOnlyCollection<IMessageComponent>)
Creates a new builder from the provided list of components.
public static ComponentBuilder FromComponents(IReadOnlyCollection<IMessageComponent> components)
Parameters
components
IReadOnlyCollection<IMessageComponent>The components to create the builder from.
Returns
- ComponentBuilder
The newly created builder.
WithTextInput(TextInputBuilder, int)
Adds a TextInputBuilder to the ModalComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.
public ModalComponentBuilder WithTextInput(TextInputBuilder text, int row = 0)
Parameters
text
TextInputBuilderThe TextInputBuilder to add.
row
intThe row to add the text input.
Returns
- ModalComponentBuilder
The current builder.
Exceptions
- InvalidOperationException
There are no more rows to add a text input to.
- ArgumentException
row
must be less than MaxActionRowCount.
WithTextInput(string, string, TextInputStyle, string, int?, int?, int, bool?, string)
Adds a TextInputBuilder to the ComponentBuilder at the specific row. If the row cannot accept the component then it will add it to a row that can.
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)
Parameters
label
stringThe input's label.
customId
stringThe input's custom id.
style
TextInputStyleThe input's style.
placeholder
stringThe input's placeholder text.
minLength
int?The input's minimum length.
maxLength
int?The input's maximum length.
row
intrequired
bool?value
string
Returns
- ModalComponentBuilder
The current builder.