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
stringThe modal's title.
customId
stringThe modal's customId.
components
ModalComponentBuilderThe 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
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
TextInputBuilderThe component to add.
row
intThe 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
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.
required
bool?value
string
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<TMessageComponent>(string)
Gets a TMessageComponent
by the specified customId
.
public TMessageComponent GetComponent<TMessageComponent>(string customId) where TMessageComponent : class, IMessageComponent
Parameters
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
Returns
- ModalBuilder
The current builder.
RemoveComponentsOfType(ComponentType)
Removes all components of the given type
from this builder.
public ModalBuilder RemoveComponentsOfType(ComponentType type)
Parameters
type
ComponentTypeThe 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
stringThe 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
Returns
- ModalBuilder
The current builder.
WithCustomId(string)
Sets the custom id of the current modal.
public ModalBuilder WithCustomId(string customId)
Parameters
customId
stringThe 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
stringThe value to set the title to.
Returns
- ModalBuilder
The current builder.