TextInputBuilder

export declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent>
export declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent>
A builder that creates API-compatible JSON data for text inputs.
constructor(data?)
Creates a new text input from API data.
Example
Creating a text input from an API data object:
const textInput = new TextInputBuilder({
custom_id: 'a cool text input',
label: 'Type something',
style: TextInputStyle.Short,
});
const textInput = new TextInputBuilder({
custom_id: 'a cool text input',
label: 'Type something',
style: TextInputStyle.Short,
});
Example
Creating a text input using setters and API data:
const textInput = new TextInputBuilder({
label: 'Type something else',
})
.setCustomId('woah')
.setStyle(TextInputStyle.Paragraph);
const textInput = new TextInputBuilder({
label: 'Type something else',
})
.setCustomId('woah')
.setStyle(TextInputStyle.Paragraph);
NameTypeOptionalDescription
dataPartial<APITextInputComponent>Yes
The API data to create this text input with
clearMaxLength():this
Clears the maximum length of text for this text input.
clearMinLength():this
Clears the minimum length of text for this text input.
clearPlaceholder():this
Clears the placeholder for this text input.
clearValue():this
Clears the value for this text input.
setCustomId(customId):this
Sets the custom id for this text input.
NameTypeOptionalDescription
customIdstringNo
The custom id to use
setLabel(label):this
Sets the label for this text input.
NameTypeOptionalDescription
labelstringNo
The label to use
setMaxLength(maxLength):this
Sets the maximum length of text for this text input.
NameTypeOptionalDescription
maxLengthnumberNo
The maximum length of text for this text input
setMinLength(minLength):this
Sets the minimum length of text for this text input.
NameTypeOptionalDescription
minLengthnumberNo
The minimum length of text for this text input
setPlaceholder(placeholder):this
Sets the placeholder for this text input.
NameTypeOptionalDescription
placeholderstringNo
The placeholder to use
setRequired(required?):this
Sets whether this text input is required.
NameTypeOptionalDescription
requiredbooleanYes
Whether this text input is required
setStyle(style):this
Sets the style for this text input.
NameTypeOptionalDescription
styleTextInputStyleNo
The style to use
setValue(value):this
Sets the value for this text input.
NameTypeOptionalDescription
valuestringNo
The value to use
toJSON(validationOverride?):APITextInputComponent
Serializes this builder to API-compatible JSON data.
Note that by disabling validation, there is no guarantee that the resulting object will be valid.
NameTypeOptionalDescription
validationOverridebooleanYes
Force validation to run/not run regardless of your global preference