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 class
TextInput.Style
A 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 String
getCustomId()
Gets the text input's custom id.Optional<String>
getLabel()
Gets the text input's labelint
getMaxLength()
Gets the text input's maximum length requirement.int
getMinLength()
Gets the text input's minimum length requirement.Optional<String>
getPlaceholder()
Gets the text input's placeholder text, if any.TextInput.Style
getStyle()
Gets the text input's style.Optional<String>
getValue()
Gets text input's value, if any.boolean
isRequired()
Gets whether the text input is required to be filled.static TextInput
paragraph(String customId)
Creates aparagraph
button.static TextInput
paragraph(String customId, String label)
Creates aparagraph
button.static TextInput
paragraph(String customId, String label, int minLength, int maxLength)
Creates aparagraph
button.static TextInput
paragraph(String customId, String label, String placeholder)
Creates aparagraph
button.TextInput
placeholder(String value)
Creates a new text input with the same data as this, but with placeholder text.TextInput
prefilled(String value)
Creates a new text input with the same data as this, but with a pre-filled value.TextInput
required()
Creates a new text input with the same data as this one, but required.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.static TextInput
small(String customId)
Creates ashort
button.static TextInput
small(String customId, String label)
Creates ashort
button.static TextInput
small(String customId, String label, int minLength, int maxLength)
Creates ashort
button.static TextInput
small(String customId, String label, String placeholder)
Creates ashort
button.-
Methods inherited from class discord4j.core.object.component.MessageComponent
fromData, getData, getType
-
-
-
-
Method Detail
-
small
public static TextInput small(String customId)
Creates ashort
button.- 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 ashort
button.- 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 ashort
button.- 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 ashort
button.- 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 aparagraph
button.- 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 aparagraph
button.- 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 aparagraph
button.- 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 aparagraph
button.- 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.
-
-