All Superinterfaces:
ActionComponent, Component, ItemComponent, SerializableData

public interface TextInput extends ActionComponent
Represents a Discord Text input component

Must be used in Modals!

  • Field Details

    • MAX_VALUE_LENGTH

      static final int MAX_VALUE_LENGTH
      The maximum length a TextInput value can have. (4000)
      See Also:
    • MAX_ID_LENGTH

      static final int MAX_ID_LENGTH
      The maximum length a TextInput custom id can have. (100)
      See Also:
    • MAX_PLACEHOLDER_LENGTH

      static final int MAX_PLACEHOLDER_LENGTH
      The maximum length a TextInput placeholder can have. (100)
      See Also:
    • MAX_LABEL_LENGTH

      static final int MAX_LABEL_LENGTH
      The maximum length a TextInput label can have. (45)
      See Also:
  • Method Details

    • getStyle

      The TextInputStyle of this TextInput component.
      Returns:
      The style of this TextInput component.
    • getId

      @Nonnull String getId()
      The custom id of this TextInput component.

      This is used to uniquely identify the TextInput. Similar to Buttons.

      Specified by:
      getId in interface ActionComponent
      Returns:
      The custom id of this component.
      See Also:
    • getLabel

      @Nonnull String 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

      @Nullable String 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

      @Nullable String 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() or ActionComponent.asEnabled() to create enabled/disabled instances.

      Specified by:
      isDisabled in interface ActionComponent
      Returns:
      True, if this button is disabled
    • withDisabled

      @Nonnull default ActionComponent withDisabled(boolean disabled)
      Description copied from interface: ActionComponent
      Returns a copy of this component with ActionComponent.isDisabled() set to the provided value.
      Specified by:
      withDisabled in interface ActionComponent
      Parameters:
      disabled - True, if this component should be disabled
      Returns:
      New enabled/disabled component instance
    • getType

      @Nonnull default Component.Type getType()
      Description copied from interface: Component
      The type of component.
      Specified by:
      getType in interface Component
      Returns:
      Component.Type
    • create

      Creates a new TextInput Builder.
      Parameters:
      id - The custom id
      label - The label
      style - The TextInputStyle
      Returns:
      a new TextInput Builder.
      Throws:
      IllegalArgumentException -
      • If either id or label are null or blank
      • If style is null or UNKNOWN
      • If id is longer than 100 characters
      • If label is longer than 45 characters