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
- titlestring
- The modal's title. 
- customIdstring
- The modal's customId. 
- componentsModalComponentBuilder
- 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
CustomId
Gets or sets the custom ID of the current modal.
public string CustomId { get; set; }Property Value
Title
Gets or sets the title of the current modal.
public string Title { get; set; }Property Value
Methods
AddComponents(List<IMessageComponent>, int)
Adds multiple components to the current builder.
public ModalBuilder AddComponents(List<IMessageComponent> components, int row)Parameters
- componentsList<IMessageComponent>
- The components to add. 
- rowint
Returns
- ModalBuilder
- The current builder 
AddTextInput(TextInputBuilder, int)
Adds a component to the current builder.
public ModalBuilder AddTextInput(TextInputBuilder component, int row = 0)Parameters
- componentTextInputBuilder
- The component to add. 
- rowint
- 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
- labelstring
- The input's label. 
- customIdstring
- The input's custom id. 
- styleTextInputStyle
- The input's style. 
- placeholderstring
- The input's placeholder text. 
- minLengthint?
- The input's minimum length. 
- maxLengthint?
- The input's maximum length. 
- requiredbool?
- valuestring
Returns
- ModalBuilder
- The current builder. 
Build()
Builds this builder into a Modal.
public Modal Build()Returns
Exceptions
- ArgumentException
- Modals must have a custom ID. 
- ArgumentException
- Modals must have a title. 
- ArgumentException
- Only components of type TextInputComponent are allowed. 
GetComponent<TMessageComponentBuilder>(string)
Gets a TMessageComponentBuilder by the specified customId.
public TMessageComponentBuilder GetComponent<TMessageComponentBuilder>(string customId) where TMessageComponentBuilder : class, IInteractableComponentBuilderParameters
Returns
- TMessageComponentBuilder
- The component of type - TMessageComponentBuilderthat 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
Returns
- ModalBuilder
- The current builder. 
RemoveComponentsOfType(ComponentType)
Removes all components of the given type from this builder.
public ModalBuilder RemoveComponentsOfType(ComponentType type)Parameters
- typeComponentType
- 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
- customIdstring
- The CustomId of the input to update. 
- updateTextInputAction<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
Returns
- ModalBuilder
- The current builder. 
WithCustomId(string)
Sets the custom id of the current modal.
public ModalBuilder WithCustomId(string customId)Parameters
- customIdstring
- 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
- titlestring
- The value to set the title to. 
Returns
- ModalBuilder
- The current builder.