Package discord4j.core.object.component
Class TextInput
- java.lang.Object
-
- discord4j.core.object.component.MessageComponent
-
- discord4j.core.object.component.ActionComponent
-
- discord4j.core.object.component.TextInput
-
public class TextInput extends ActionComponent
A modal-only text input field- See Also:
- Text Inputs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTextInput.StyleA text input's style is what determines its size and behavior-
Nested classes/interfaces inherited from class discord4j.core.object.component.MessageComponent
MessageComponent.Type
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCustomId()Gets the text input's custom id.Optional<String>getLabel()Gets the text input's labelintgetMaxLength()Gets the text input's maximum length requirement.intgetMinLength()Gets the text input's minimum length requirement.Optional<String>getPlaceholder()Gets the text input's placeholder text, if any.TextInput.StylegetStyle()Gets the text input's style.Optional<String>getValue()Gets text input's value, if any.booleanisRequired()Gets whether the text input is required to be filled.static TextInputparagraph(String customId)Creates aparagraphbutton.static TextInputparagraph(String customId, String label)Creates aparagraphbutton.static TextInputparagraph(String customId, String label, int minLength, int maxLength)Creates aparagraphbutton.static TextInputparagraph(String customId, String label, String placeholder)Creates aparagraphbutton.TextInputplaceholder(String value)Creates a new text input with the same data as this, but with placeholder text.TextInputprefilled(String value)Creates a new text input with the same data as this, but with a pre-filled value.TextInputrequired()Creates a new text input with the same data as this one, but required.TextInputrequired(boolean value)Creates a new text input with the same data as this one, but depending on the value param it may be required or not.static TextInputsmall(String customId)Creates ashortbutton.static TextInputsmall(String customId, String label)Creates ashortbutton.static TextInputsmall(String customId, String label, int minLength, int maxLength)Creates ashortbutton.static TextInputsmall(String customId, String label, String placeholder)Creates ashortbutton.-
Methods inherited from class discord4j.core.object.component.MessageComponent
fromData, getData, getType
-
-
-
-
Method Detail
-
small
public static TextInput small(String customId)
Creates ashortbutton.- Parameters:
customId- A developer-defined identifier for the button.- Returns:
- A button with the given data.
-
small
public static TextInput small(String customId, String label)
Creates ashortbutton.- Parameters:
customId- A developer-defined identifier for the button.label- The text that appears above the input- Returns:
- A button with the given data.
-
small
public static TextInput small(String customId, String label, String placeholder)
Creates ashortbutton.- Parameters:
customId- A developer-defined identifier for the button.label- The text that appears above the inputplaceholder- The placeholder text to be displayed- Returns:
- A button with the given data.
-
small
public static TextInput small(String customId, String label, int minLength, int maxLength)
Creates ashortbutton.- Parameters:
customId- A developer-defined identifier for the button.label- The text that appears above the inputminLength- The minimum length the user is required to inputmaxLength- The maximum length the user is required to input- Returns:
- A button with the given data.
-
paragraph
public static TextInput paragraph(String customId)
Creates aparagraphbutton.- Parameters:
customId- A developer-defined identifier for the button.- Returns:
- A button with the given data.
-
paragraph
public static TextInput paragraph(String customId, String label)
Creates aparagraphbutton.- Parameters:
customId- A developer-defined identifier for the button.label- The text that appears above the input- Returns:
- A button with the given data.
-
paragraph
public static TextInput paragraph(String customId, String label, String placeholder)
Creates aparagraphbutton.- Parameters:
customId- A developer-defined identifier for the button.label- The text that appears above the inputplaceholder- The placeholder text to display- Returns:
- A button with the given data.
-
paragraph
public static TextInput paragraph(String customId, String label, int minLength, int maxLength)
Creates aparagraphbutton.- Parameters:
customId- A developer-defined identifier for the button.label- The text that appears above the inputminLength- The minimum length the user is required to inputmaxLength- The maximum length the user is required to input- Returns:
- A button with the given data.
-
getStyle
public TextInput.Style getStyle()
Gets the text input's style.- Returns:
- the style of the text input
-
getCustomId
public String getCustomId()
Gets the text input's custom id.- Returns:
- the custom id of the text input
-
getLabel
public Optional<String> getLabel()
Gets the text input's label- Returns:
- The text input's label
-
getMinLength
public int getMinLength()
Gets the text input's minimum length requirement. If not present, defaults to0.- Returns:
- The text input's minimum length
-
getMaxLength
public int getMaxLength()
Gets the text input's maximum length requirement. If not present, defaults to4000- Returns:
- The text input's maximum length
-
isRequired
public boolean isRequired()
Gets whether the text input is required to be filled. Defaults totrue- Returns:
- Whether the text input is required
-
getValue
public Optional<String> getValue()
Gets text input's value, if any.- Returns:
- The text input's value
-
getPlaceholder
public Optional<String> getPlaceholder()
Gets the text input's placeholder text, if any.- Returns:
- The text input's placeholder
-
required
public TextInput required()
Creates a new text input with the same data as this one, but required.- Returns:
- A new required text input with the same data as this one.
-
required
public TextInput required(boolean value)
Creates a new text input with the same data as this one, but depending on the value param it may be required or not.- Parameters:
value- True if the text input should be required otherwise False.- Returns:
- A new possibly required button with the same data as this one.
-
prefilled
public TextInput prefilled(String value)
Creates a new text input with the same data as this, but with a pre-filled value.- Parameters:
value- The pre-filled text value- Returns:
- A new text input with the same data as this one.
-
-