export declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>>
export declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>>
A builder that creates API-compatible JSON data for text inputs.
Extends
ComponentBuilder<APITextInputComponent>Implements
Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>>constructor(data?)
Creates a new text input from API data.
Example
Creating a select menu option from an API data object:const textInput = new TextInputBuilder({
custom_id: 'a cool select menu',
label: 'Type something',
style: TextInputStyle.Short,
});
const textInput = new TextInputBuilder({
custom_id: 'a cool select menu',
label: 'Type something',
style: TextInputStyle.Short,
});
Example
Creating a select menu option 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);
Name | Type | Optional | Description |
---|---|---|---|
data | APITextInputComponent & { type?: ComponentType.TextInput; } | Yes | The API data to create this text input with |
Readonly
data
:
Partial<DataType>
The API data associated with this component.
Inherited from ComponentBuilderequals(other)
:
boolean
Name | Type | Optional | Description |
---|---|---|---|
other | APITextInputComponent | JSONEncodable<APITextInputComponent> | No | None |
setCustomId(customId)
:
this
Sets the custom id for this text input.
Name | Type | Optional | Description |
---|---|---|---|
customId | string | No | The custom id to use |
setLabel(label)
:
this
Sets the label for this text input.
Name | Type | Optional | Description |
---|---|---|---|
label | string | No | The label to use |
setMaxLength(maxLength)
:
this
Sets the maximum length of text for this text input.
Name | Type | Optional | Description |
---|---|---|---|
maxLength | number | No | The maximum length of text for this text input |
setMinLength(minLength)
:
this
Sets the minimum length of text for this text input.
Name | Type | Optional | Description |
---|---|---|---|
minLength | number | No | The minimum length of text for this text input |
setPlaceholder(placeholder)
:
this
Sets the placeholder for this text input.
Name | Type | Optional | Description |
---|---|---|---|
placeholder | string | No | The placeholder to use |
setRequired(required?)
:
this
Sets whether this text input is required.
Name | Type | Optional | Description |
---|---|---|---|
required | boolean | Yes | Whether this text input is required |
setStyle(style)
:
this
Sets the style for this text input.
Name | Type | Optional | Description |
---|---|---|---|
style | TextInputStyle | No | The style to use |
setValue(value)
:
this
Sets the value for this text input.
Name | Type | Optional | Description |
---|---|---|---|
value | string | No | The value to use |
toJSON()
:
APITextInputComponent
Serializes this builder to API-compatible JSON data.