Class TextInputBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a builder for creating a TextInputComponent.
public class TextInputBuilder : IInteractableComponentBuilder, IMessageComponentBuilder
- Inheritance
-
TextInputBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
TextInputBuilder()
Creates a new instance of a TextInputBuilder.
public TextInputBuilder()
TextInputBuilder(TextInputComponent)
Creates a new instance of a TextInputBuilder from existing component.
public TextInputBuilder(TextInputComponent textInput)
Parameters
textInputTextInputComponent
TextInputBuilder(string, string, TextInputStyle, string, int?, int?, bool?, string, int?)
Creates a new instance of a TextInputBuilder.
public TextInputBuilder(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)
Parameters
labelstringThe text input's label.
customIdstringThe text input's custom id.
styleTextInputStyleThe text input's style.
placeholderstringThe text input's placeholder.
minLengthint?The text input's minimum length.
maxLengthint?The text input's maximum length.
requiredbool?The text input's required value.
valuestringidint?
Fields
LargestMaxLength
public const int LargestMaxLength = 4000
Field Value
MaxPlaceholderLength
The max length of a Placeholder.
public const int MaxPlaceholderLength = 100
Field Value
Properties
CustomId
Gets or sets the custom id of the current text input.
public string CustomId { get; set; }
Property Value
Exceptions
- ArgumentException
CustomId length exceeds MaxCustomIdLength
- ArgumentException
CustomId length subceeds 1.
Id
Gets or sets the id for the component. An autoincremented id will be assigned if not set.
public int? Id { get; set; }
Property Value
- int?
Label
Gets or sets the label of the current text input.
public string Label { get; set; }
Property Value
MaxLength
Gets or sets the maximum length of the current text input.
public int? MaxLength { get; set; }
Property Value
- int?
Exceptions
- ArgumentOutOfRangeException
MaxLength is less than 0.
- ArgumentOutOfRangeException
MaxLength is greater than LargestMaxLength.
- ArgumentOutOfRangeException
MinLength
Gets or sets the minimum length of the current text input.
public int? MinLength { get; set; }
Property Value
- int?
Exceptions
- ArgumentOutOfRangeException
MinLength is less than 0.
- ArgumentOutOfRangeException
MinLength is greater than LargestMaxLength.
- ArgumentOutOfRangeException
Placeholder
Gets or sets the placeholder of the current text input.
public string Placeholder { get; set; }
Property Value
Exceptions
- ArgumentException
Placeholder is longer than MaxPlaceholderLength characters
Required
Gets or sets whether the user is required to input text.
public bool? Required { get; set; }
Property Value
- bool?
Style
Gets or sets the style of the current text input.
public TextInputStyle Style { get; set; }
Property Value
Type
Gets the type of the component.
public ComponentType Type { get; }
Property Value
Value
Gets or sets the default value of the text input.
public string Value { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Value.Length is less than 0.
- ArgumentOutOfRangeException
Value.Length is greater than LargestMaxLength or MaxLength.
- ArgumentException
Methods
Build()
public TextInputComponent Build()
Returns
WithCustomId(string)
Sets the custom id of the current builder.
public TextInputBuilder WithCustomId(string customId)
Parameters
customIdstringThe value to set.
Returns
- TextInputBuilder
The current builder.
WithLabel(string)
Sets the label of the current builder.
public TextInputBuilder WithLabel(string label)
Parameters
labelstringThe value to set.
Returns
- TextInputBuilder
The current builder.
WithMaxLength(int)
Sets the maximum length of the current builder.
public TextInputBuilder WithMaxLength(int maxLength)
Parameters
maxLengthintThe value to set.
Returns
- TextInputBuilder
The current builder.
WithMinLength(int)
Sets the minimum length of the current builder.
public TextInputBuilder WithMinLength(int minLength)
Parameters
minLengthintThe value to set.
Returns
- TextInputBuilder
The current builder.
WithPlaceholder(string)
Sets the placeholder of the current builder.
public TextInputBuilder WithPlaceholder(string placeholder)
Parameters
placeholderstringThe value to set.
Returns
- TextInputBuilder
The current builder.
WithRequired(bool)
Sets the required value of the current builder.
public TextInputBuilder WithRequired(bool required)
Parameters
requiredboolThe value to set.
Returns
- TextInputBuilder
The current builder.
WithStyle(TextInputStyle)
Sets the style of the current builder.
public TextInputBuilder WithStyle(TextInputStyle style)
Parameters
styleTextInputStyleThe value to set.
Returns
- TextInputBuilder
The current builder.
WithValue(string)
Sets the value of the current builder.
public TextInputBuilder WithValue(string value)
Parameters
valuestringThe value to set
Returns
- TextInputBuilder
The current builder.