Interface CheckboxGroup
- All Superinterfaces:
Component, ICustomId, LabelChildComponent
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface Component
Component.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length of a checkbox group's custom ID.static final intThe maximum number of options a checkbox group can have. -
Method Summary
Modifier and TypeMethodDescriptionstatic CheckboxGroup.BuilderCreates a new checkbox group builder with the provided custom ID.default CheckboxGroup.BuilderCreates a new preconfiguredCheckboxGroup.Builderwith the same settings used for this checkbox group.An unique component ID ornull.intThe maximum number of values the user can select.intThe minimum number of values the user has to select.@Unmodifiable List<CheckboxGroupOption> Returns an immutable list of the options available for this checkbox group.booleanWhether this checkbox group should, if at least one option is selected, enforce the value range before sending.withUniqueId(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from interface Component
getType, getUniqueId, isMessageCompatible, isModalCompatible
-
Field Details
-
CUSTOM_ID_MAX_LENGTH
static final int CUSTOM_ID_MAX_LENGTHThe maximum length of a checkbox group's custom ID. (100)- See Also:
-
OPTIONS_MAX_AMOUNT
static final int OPTIONS_MAX_AMOUNTThe maximum number of options a checkbox group can have. (10)- See Also:
-
-
Method Details
-
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 interfaceICustomId- Specified by:
withUniqueIdin interfaceLabelChildComponent- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-
getCustomId
Description copied from interface:ICustomIdAn unique component ID ornull.
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 useComponent.getUniqueId()to identify a component in a single message, such as when replacing components usingComponentTreeorIReplaceable.replace(ComponentReplacer).- Specified by:
getCustomIdin interfaceICustomId- Returns:
- The component ID or null if not present
- See Also:
-
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:
trueif the value range should be enforced
-
create
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 isnullor blank
-
createCopy
Creates a new preconfiguredCheckboxGroup.Builderwith 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.Builderused to create the checkbox group
-