Interface TextInput
- All Superinterfaces:
ActionComponent
,ActionRowChildComponent
,Component
,IDisableable
- All Known Implementing Classes:
TextInputImpl
Represents a Discord Text input component
Must be used in Modals
!
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.dv8tion.jda.api.components.Component
Component.Type
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The maximum length a TextInput custom id can have.static final int
The maximum length a TextInput label can have.static final int
The maximum length a TextInput placeholder can have.static final int
The maximum length a TextInput value can have. -
Method Summary
Modifier and TypeMethodDescriptiondefault TextInput
Returns a copy of this component withActionComponent.isDisabled()
set to true.default TextInput
Returns a copy of this component withActionComponent.isDisabled()
set to false.static TextInput.Builder
create
(String id, String label, TextInputStyle style) Creates a new TextInput Builder.The custom id of this TextInput component.getLabel()
The label of this TextInput component.int
The maximum amount of characters that can be written to submit the Modal.int
The minimum amount of characters that must be written to submit the Modal.The placeholder of this TextInput component.getStyle()
TheTextInputStyle
of this TextInput component.default Component.Type
getType()
The type of component.getValue()
The pre-defined value of this TextInput component.default boolean
Whether this action component is disabled.boolean
Whether this TextInput is required to be non-emptydefault TextInput
withDisabled
(boolean disabled) Returns a copy of this component withActionComponent.isDisabled()
set to the provided value.withUniqueId
(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from interface net.dv8tion.jda.api.components.ActionComponent
getId
Methods inherited from interface net.dv8tion.jda.api.components.Component
getUniqueId, isMessageCompatible, isModalCompatible
Methods inherited from interface net.dv8tion.jda.api.components.attribute.IDisableable
isEnabled
-
Field Details
-
MAX_VALUE_LENGTH
static final int MAX_VALUE_LENGTHThe maximum length a TextInput value can have. (4000)- See Also:
-
MAX_ID_LENGTH
static final int MAX_ID_LENGTHThe maximum length a TextInput custom id can have. (100)- See Also:
-
MAX_PLACEHOLDER_LENGTH
static final int MAX_PLACEHOLDER_LENGTHThe maximum length a TextInput placeholder can have. (100)- See Also:
-
MAX_LABEL_LENGTH
static final int MAX_LABEL_LENGTHThe maximum length a TextInput label can have. (45)- See Also:
-
-
Method Details
-
getStyle
TheTextInputStyle
of this TextInput component.- Returns:
- The style of this TextInput component.
-
getCustomId
The custom id of this TextInput component.This is used to uniquely identify the TextInput. Similar to
Buttons
.- Specified by:
getCustomId
in interfaceActionComponent
- Returns:
- The custom id of this component.
- See Also:
-
getLabel
The label of this TextInput component.- Returns:
- The label of this TextInput component.
-
getMinLength
int getMinLength()The minimum amount of characters that must be written to submit the Modal.This is -1 if no length has been set!
- Returns:
- The minimum length of this TextInput component or -1
-
getMaxLength
int getMaxLength()The maximum amount of characters that can be written to submit the Modal.This is -1 if no length has been set!
- Returns:
- The maximum length of this TextInput component or -1
-
isRequired
boolean isRequired()Whether this TextInput is required to be non-empty- Returns:
- True if this TextInput is required to be used.
-
getValue
The pre-defined value of this TextInput component.
If this is not null, sending a Modal with this component will pre-populate the field with this String.This is null if no pre-defined value has been set!
- Returns:
- The value of this TextInput component or null.
-
getPlaceHolder
The placeholder of this TextInput component.
This is a short hint that describes the expected value of the TextInput field.This is null if no placeholder has been set!
- Returns:
- The placeholder of this TextInput component or null.
-
isDisabled
default boolean isDisabled()Description copied from interface:ActionComponent
Whether this action component is disabled.You can use
ActionComponent.asDisabled()
orActionComponent.asEnabled()
to create enabled/disabled instances.- Specified by:
isDisabled
in interfaceActionComponent
- Specified by:
isDisabled
in interfaceIDisableable
- Returns:
- True, if this button is disabled
-
asDisabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to true.- Specified by:
asDisabled
in interfaceActionComponent
- Specified by:
asDisabled
in interfaceIDisableable
- Returns:
- New disabled component instance
- See Also:
-
asEnabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to false.- Specified by:
asEnabled
in interfaceActionComponent
- Specified by:
asEnabled
in interfaceIDisableable
- Returns:
- New enabled component instance
- See Also:
-
withDisabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to the provided value.- Specified by:
withDisabled
in interfaceActionComponent
- Specified by:
withDisabled
in interfaceIDisableable
- Parameters:
disabled
- True, if this component should be disabled- Returns:
- New enabled/disabled component instance
- See Also:
-
withUniqueId
Description copied from interface:Component
Creates a new component with the provided numeric ID.
If no ID is set, Discord will generate IDs incrementally starting from 1 and will not use existing IDs from the same message/modal.- Specified by:
withUniqueId
in interfaceActionComponent
- Specified by:
withUniqueId
in interfaceActionRowChildComponent
- Specified by:
withUniqueId
in interfaceComponent
- Specified by:
withUniqueId
in interfaceIDisableable
- Parameters:
uniqueId
- The new ID; must be higher or equal to 1- Returns:
- The new component
-
getType
Description copied from interface:Component
The type of component.- Specified by:
getType
in interfaceComponent
- Returns:
Component.Type
-
create
@Nonnull static TextInput.Builder create(@Nonnull String id, @Nonnull String label, @Nonnull TextInputStyle style) Creates a new TextInput Builder.- Parameters:
id
- The custom idlabel
- The labelstyle
- TheTextInputStyle
- Returns:
- a new TextInput Builder.
- Throws:
IllegalArgumentException
-
-