Interface Label
- All Superinterfaces:
Component, ModalTopLevelComponent
Component that contains a label, an optional description, and a child component.
Labels are used as top-level components inside Modals,
and cannot be used in Messages.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Component
Component.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length a label description can have.static final intThe maximum length a label can have. -
Method Summary
Modifier and TypeMethodDescriptiongetChild()The child component contained by this Label.The description of the Label.getLabel()The label.static Labelof(String label, String description, LabelChildComponent child) Constructs a newLabelusing the provided label, description and child component.static Labelof(String label, LabelChildComponent child) Constructs a newLabelusing the provided label and child component.withChild(LabelChildComponent child) Returns a copy of this Label with the provided child component.withDescription(String description) Returns a copy of this Label with the provided description.Returns a copy of this Label with the provided label.withUniqueId(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from interface Component
getType, getUniqueId, isMessageCompatible, isModalCompatible
-
Field Details
-
LABEL_MAX_LENGTH
static final int LABEL_MAX_LENGTHThe maximum length a label can have. (45)- See Also:
-
DESCRIPTION_MAX_LENGTH
static final int DESCRIPTION_MAX_LENGTHThe maximum length a label description can have. (100)- See Also:
-
-
Method Details
-
of
@Nonnull static Label of(@Nonnull String label, @Nullable String description, @Nonnull LabelChildComponent child) Constructs a newLabelusing the provided label, description and child component.- Parameters:
label- The label of the Labeldescription- The description of the Label. May benullchild- TheLabelChildComponentthat should be contained by the Label- Returns:
- The new
Label - Throws:
IllegalArgumentException-- If
labelisnull, blank, or longer thanLABEL_MAX_LENGTH - If
descriptionis notnulland is blank or longer thanDESCRIPTION_MAX_LENGTH - If
childisnull
- If
-
of
Constructs a newLabelusing the provided label and child component.- Parameters:
label- The label of the Labelchild- TheLabelChildComponentthat should be contained by the Label- Returns:
- The new
Label - Throws:
IllegalArgumentException-- If
labelisnull, blank, or longer thanLABEL_MAX_LENGTH - If
childisnull
- If
-
withLabel
Returns a copy of this Label with the provided label.- Parameters:
label- The label- Returns:
- The new Label
- Throws:
IllegalArgumentException- Iflabelisnull, blank, or longer thanLABEL_MAX_LENGTH
-
withDescription
Returns a copy of this Label with the provided description.- Parameters:
description- The description- Returns:
- The new Label
- Throws:
IllegalArgumentException- Ifdescriptionis notnulland is blank or longer thanDESCRIPTION_MAX_LENGTH
-
withChild
Returns a copy of this Label with the provided child component.- Parameters:
child- The child component- Returns:
- The new Label
- Throws:
IllegalArgumentException- Ifchildisnull
-
getLabel
-
getDescription
The description of the Label. May benull.- Returns:
- The description
-
getChild
The child component contained by this Label.- Returns:
- The child component
-
withUniqueId
Description copied from interface:ComponentCreates 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:
withUniqueIdin interfaceComponent- Specified by:
withUniqueIdin interfaceModalTopLevelComponent- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-