Interface Label

All Superinterfaces:
Component, ModalTopLevelComponent

public interface Label extends 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:
  • Field Details

    • LABEL_MAX_LENGTH

      static final int LABEL_MAX_LENGTH
      The maximum length a label can have. (45)
      See Also:
    • DESCRIPTION_MAX_LENGTH

      static final int DESCRIPTION_MAX_LENGTH
      The 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 new Label using the provided label, description and child component.
      Parameters:
      label - The label of the Label
      description - The description of the Label. May be null
      child - The LabelChildComponent that should be contained by the Label
      Returns:
      The new Label
      Throws:
      IllegalArgumentException -
    • of

      @Nonnull static Label of(@Nonnull String label, @Nonnull LabelChildComponent child)
      Constructs a new Label using the provided label and child component.
      Parameters:
      label - The label of the Label
      child - The LabelChildComponent that should be contained by the Label
      Returns:
      The new Label
      Throws:
      IllegalArgumentException -
    • withLabel

      @Nonnull Label withLabel(@Nonnull String label)
      Returns a copy of this Label with the provided label.
      Parameters:
      label - The label
      Returns:
      The new Label
      Throws:
      IllegalArgumentException - If label is null, blank, or longer than LABEL_MAX_LENGTH
    • withDescription

      @Nonnull Label withDescription(@Nullable String description)
      Returns a copy of this Label with the provided description.
      Parameters:
      description - The description
      Returns:
      The new Label
      Throws:
      IllegalArgumentException - If description is not null and is blank or longer than DESCRIPTION_MAX_LENGTH
    • withChild

      @Nonnull Label withChild(@Nonnull LabelChildComponent child)
      Returns a copy of this Label with the provided child component.
      Parameters:
      child - The child component
      Returns:
      The new Label
      Throws:
      IllegalArgumentException - If child is null
    • getLabel

      @Nonnull String getLabel()
      The label.
      Returns:
      The label
    • getDescription

      @Nullable String getDescription()
      The description of the Label. May be null.
      Returns:
      The description
    • getChild

      @Nonnull LabelChildComponentUnion getChild()
      The child component contained by this Label.
      Returns:
      The child component
    • withUniqueId

      @Nonnull @CheckReturnValue Label withUniqueId(int uniqueId)
      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 interface Component
      Specified by:
      withUniqueId in interface ModalTopLevelComponent
      Parameters:
      uniqueId - The new ID; must be higher or equal to 1
      Returns:
      The new component