Interface RadioGroup

All Superinterfaces:
Component, ICustomId, LabelChildComponent

public interface RadioGroup extends ICustomId, LabelChildComponent
A component displaying a group of up to 10 radio buttons, in which only one can be chosen.

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 radio group's custom ID. (100)
      See Also:
    • OPTIONS_MAX_AMOUNT

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

    • withUniqueId

      @Nonnull RadioGroup 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<RadioGroupOption> getOptions()
      Returns an immutable list of the options available for this radio group.
      Returns:
      Immutable list of this radio group's options
    • isRequired

      boolean isRequired()
      Whether this radio group requires an option to be selected.
      Returns:
      true if an option must be selected by the user
    • create

      @Nonnull static RadioGroup.Builder create(@Nonnull String customId)
      Creates a new radio 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 RadioGroup.Builder createCopy()
      Creates a new preconfigured RadioGroup.Builder with the same settings used for this radio group.
      This can be useful to create an updated version of this radio group without needing to rebuild it from scratch.
      Returns:
      The RadioGroup.Builder used to create the radio group