Search...

TextInputBuilder

export declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>> 
export declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>> 

No summary provided.

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);
NameTypeOptionalDescription
dataAPITextInputComponent & { type?: ComponentType.TextInput; }YesThe API data to create this text input with
Readonly

data

:

Partial<DataType>

The API data associated with this component
Inherited from ComponentBuilder

equals(other)

:

boolean

NameTypeOptionalDescription
otherAPITextInputComponent | JSONEncodable<APITextInputComponent>NoNone

setCustomId(customId)

:

this

Sets the custom id for this text input
NameTypeOptionalDescription
customIdstringNoThe custom id of this text input

setLabel(label)

:

this

Sets the label for this text input
NameTypeOptionalDescription
labelstringNoThe label for this text input

setMaxLength(maxLength)

:

this

Sets the maximum length of text for this text input
NameTypeOptionalDescription
maxLengthnumberNoThe maximum length of text for this text input

setMinLength(minLength)

:

this

Sets the minimum length of text for this text input
NameTypeOptionalDescription
minLengthnumberNoThe minimum length of text for this text input

setPlaceholder(placeholder)

:

this

Sets the placeholder of this text input
NameTypeOptionalDescription
placeholderstringNoThe placeholder of this text input

setRequired(required?)

:

this

Sets whether this text input is required
NameTypeOptionalDescription
requiredbooleanYesWhether this text input is required

setStyle(style)

:

this

Sets the style for this text input
NameTypeOptionalDescription
styleTextInputStyleNoThe style for this text input

setValue(value)

:

this

Sets the value of this text input
NameTypeOptionalDescription
valuestringNoThe value for this text input

toJSON()

:

APITextInputComponent

Serializes this component to an API-compatible JSON object
Remarks
This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.