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()
Creates a new and empty ModalBuilder.
public ModalBuilder()
ModalBuilder(string, string, ModalComponentBuilder)
Creates a new instance of the ModalBuilder.
public ModalBuilder(string title, string customId, ModalComponentBuilder components = null)
Parameters
titlestringThe modal's title.
customIdstringThe modal's customId.
componentsModalComponentBuilderThe modal's components.
ModalBuilder(string, string, params IEnumerable<IMessageComponentBuilder>)
Creates a new instance of the ModalBuilder.
public ModalBuilder(string title, string customId, params IEnumerable<IMessageComponentBuilder> components)
Parameters
titlestringThe modal's title.
customIdstringThe modal's customId.
componentsIEnumerable<IMessageComponentBuilder>The modal's components.
ModalBuilder(string, string, params IEnumerable<IMessageComponent>)
Creates a new instance of the ModalBuilder.
public ModalBuilder(string title, string customId, params IEnumerable<IMessageComponent> components)
Parameters
titlestringThe modal's title.
customIdstringThe modal's customId.
componentsIEnumerable<IMessageComponent>The modal's components.
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(params IEnumerable<IMessageComponentBuilder>)
Adds multiple components to the current builder.
public ModalBuilder AddComponents(params IEnumerable<IMessageComponentBuilder> components)
Parameters
componentsIEnumerable<IMessageComponentBuilder>The components to add.
Returns
- ModalBuilder
The current builder
AddComponents(List<IMessageComponent>, int)
Adds multiple components to the current builder.
[Obsolete("Modal components no longer have rows", false)]
public ModalBuilder AddComponents(List<IMessageComponent> components, int row)
Parameters
componentsList<IMessageComponent>The components to add.
rowint
Returns
- ModalBuilder
The current builder
AddFileUpload(string, FileUploadComponentBuilder, string, int?)
Constructs and adds a LabelBuilder with the provided FileUploadComponentBuilder to the current ModalComponentBuilder.
public ModalBuilder AddFileUpload(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
- ModalBuilder
The current ModalComponentBuilder.
AddFileUpload(string, string, int?, int?, bool, int?, string, int?)
Constructs and adds a LabelBuilder with a FileUploadComponentBuilder to the current ModalComponentBuilder.
public ModalBuilder AddFileUpload(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
- ModalBuilder
The current ModalComponentBuilder.
AddLabel(LabelBuilder)
Adds a LabelBuilder to the current ModalComponentBuilder.
public ModalBuilder AddLabel(LabelBuilder label)
Parameters
labelLabelBuilderThe LabelBuilder to add.
Returns
- ModalBuilder
The current ModalComponentBuilder.
AddLabel(string, IMessageComponentBuilder, string, int?)
Constructs and adds a LabelBuilder to the current ModalComponentBuilder.
public ModalBuilder AddLabel(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
- ModalBuilder
The current ModalComponentBuilder.
AddSelectMenu(string, SelectMenuBuilder, string, int?)
Constructs and adds a LabelBuilder with the provided SelectMenuBuilder to the current ModalComponentBuilder.
public ModalBuilder AddSelectMenu(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
- ModalBuilder
The current ModalComponentBuilder.
AddSelectMenu(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 ModalBuilder AddSelectMenu(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
- ModalBuilder
The current ModalComponentBuilder.
AddTextDisplay(TextDisplayBuilder)
Adds a TextDisplayBuilder to the current ModalComponentBuilder.
public ModalBuilder AddTextDisplay(TextDisplayBuilder textDisplay)
Parameters
textDisplayTextDisplayBuilderThe TextDisplayBuilder to add.
Returns
- ModalBuilder
The current ModalComponentBuilder.
AddTextDisplay(string, int?)
Constructs and adds a TextDisplayBuilder to the current ModalComponentBuilder.
public ModalBuilder AddTextDisplay(string content, int? id = null)
Parameters
contentstringThe content of the TextDisplayBuilder.
idint?The id of the TextDisplayBuilder.
Returns
- ModalBuilder
The current ModalComponentBuilder.
AddTextInput(TextInputBuilder, int)
Adds a component to the current builder.
[Obsolete("Modal components no longer have rows", false)]
public ModalBuilder AddTextInput(TextInputBuilder component, int row)
Parameters
componentTextInputBuilderThe component to add.
rowintThe row to add the text input.
Returns
- ModalBuilder
The current builder.
AddTextInput(string, string, TextInputStyle, string, int?, int?, bool?, string, int?, string, int?)
Constructs and adds a LabelBuilder with a TextInputBuilder to the current ModalComponentBuilder.
public ModalBuilder AddTextInput(string label, string customId, TextInputStyle style = TextInputStyle.Short, string placeholder = null, int? minLength = null, int? maxLength = null, 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.
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
- ModalBuilder
The current ModalComponentBuilder.
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(string)
Gets a IInteractableComponentBuilder by the specified customId.
public IInteractableComponentBuilder GetComponent(string customId)
Parameters
Returns
- IInteractableComponentBuilder
The component that was found, null otherwise.
GetComponent<TMessageComponentBuilder>(string)
Gets a TMessageComponentBuilder by the specified customId.
public TMessageComponentBuilder GetComponent<TMessageComponentBuilder>(string customId) where TMessageComponentBuilder : class, IInteractableComponentBuilder
Parameters
Returns
- TMessageComponentBuilder
The component of type
TMessageComponentBuilderthat was found, null otherwise.
Type Parameters
TMessageComponentBuilderThe 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
typeComponentTypeThe 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
customIdstringThe 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
customIdstringThe 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
titlestringThe value to set the title to.
Returns
- ModalBuilder
The current builder.