Interface CheckboxGroup

All Superinterfaces:
Component, ICustomId, LabelChildComponent

public interface CheckboxGroup extends ICustomId, LabelChildComponent
A component displaying a group of up to 10 checkboxes which can be checked independently.

Must be used inside Labels only!

See Also:
  • Field Details

    • CUSTOM_ID_MAX_LENGTH

      static final int CUSTOM_ID_MAX_LENGTH
      The maximum length of a checkbox group's custom ID. (100)
      See Also:
    • OPTIONS_MAX_AMOUNT

      static final int OPTIONS_MAX_AMOUNT
      The maximum number of options a checkbox group can have. (10)
      See Also:
  • Method Details

    • withUniqueId

      @Nonnull CheckboxGroup 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 ICustomId
      Specified by:
      withUniqueId in interface LabelChildComponent
      Parameters:
      uniqueId - The new ID; must be higher or equal to 1
      Returns:
      The new component
    • getCustomId

      @Nonnull String getCustomId()
      Description copied from interface: ICustomId
      An unique component ID or null.
      Some components such as link buttons don't have this.

      Custom IDs can contain custom data, this is typically used to pass data between a slash command and your button listener.

      While this ID is unique and can be retrieved with ComponentInteraction.getComponentId(), you should use Component.getUniqueId() to identify a component in a single message, such as when replacing components using ComponentTree or IReplaceable.replace(ComponentReplacer).

      Specified by:
      getCustomId in interface ICustomId
      Returns:
      The component ID or null if not present
      See Also:
    • getOptions

      @Nonnull @Unmodifiable List<CheckboxGroupOption> getOptions()
      Returns an immutable list of the options available for this checkbox group.
      Returns:
      Immutable list of this checkbox group's options
    • getMinValues

      int getMinValues()
      The minimum number of values the user has to select.
      Returns:
      Minimum number of values the user has to select
    • getMaxValues

      int getMaxValues()
      The maximum number of values the user can select.
      Returns:
      Maximum number of values the user can select
    • isRequired

      boolean isRequired()
      Whether this checkbox group should, if at least one option is selected, enforce the value range before sending.
      Returns:
      true if the value range should be enforced
    • create

      @Nonnull static CheckboxGroup.Builder create(@Nonnull String customId)
      Creates a new checkbox group builder with the provided custom ID.
      Parameters:
      customId - The custom ID, can be used to pass data to handlers
      Returns:
      The new builder
      Throws:
      IllegalArgumentException - If the ID is null or blank
    • createCopy

      @Nonnull default CheckboxGroup.Builder createCopy()
      Creates a new preconfigured CheckboxGroup.Builder with the same settings used for this checkbox group.
      This can be useful to create an updated version of this checkbox group without needing to rebuild it from scratch.
      Returns:
      The CheckboxGroup.Builder used to create the checkbox group