Interface ActionRow
- All Superinterfaces:
Component
,ContainerChildComponent
,IDisableable
,IReplaceable
,MessageTopLevelComponent
,ModalTopLevelComponent
- All Known Implementing Classes:
ActionRowImpl
public interface ActionRow
extends MessageTopLevelComponent, ModalTopLevelComponent, ContainerChildComponent, IReplaceable, IDisableable
One row of action components.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.components.Component
Component.Type
-
Method Summary
Modifier and TypeMethodDescriptiondefault ActionRow
Returns a new instance of this component in a disabled state.default ActionRow
Returns a new instance of this component in an enabled state.default @Unmodifiable List
<ActionComponent> Returns an immutable list ofActionComponents
in this row.Returns an immutable list ofButtons
in this row.@Unmodifiable List
<ActionRowChildComponentUnion> Returns an unmodifiable list of the components contained in this action row.static int
getMaxAllowed
(Component.Type type) How many of components of the provided type can be added to a singleActionRow
.default boolean
Whether this component is disabled.default boolean
Whether this component is enabled.default boolean
Whether this Component is compatible withMessages
.default boolean
Whether this Component is compatible withModals
.static ActionRow
of
(Collection<? extends ActionRowChildComponent> components) Create one row ofcomponents
.static ActionRow
of
(ActionRowChildComponent... components) Create one row ofcomponents
.partitionOf
(Collection<? extends ActionRowChildComponent> components) Partitions the providedcomponents
into a list of ActionRow instances.partitionOf
(ActionRowChildComponent... components) Partitions the providedcomponents
into a list of ActionRow instances.replace
(ComponentReplacer replacer) Replaces and/or removes children components using the providedComponentReplacer
, and construct a new component from the result.default ActionRow
withDisabled
(boolean disabled) Returns a new instance of this component in an enabled/disabled state.withUniqueId
(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from interface net.dv8tion.jda.api.components.Component
getType, getUniqueId
-
Method Details
-
of
Create one row ofcomponents
.
You cannot currently mix different types of components and each type has its own maximum defined byComponent.Type.getMaxPerRow()
.- Parameters:
components
- The components for this action row- Returns:
- The action row
- Throws:
IllegalArgumentException
- If anything is null, empty, or an invalid number of components are provided
-
of
Create one row ofcomponents
.
You cannot currently mix different types of components and each type has its own maximum defined byComponent.Type.getMaxPerRow()
.- Parameters:
components
- The components for this action row- Returns:
- The action row
- Throws:
IllegalArgumentException
- If anything is null, empty, or an invalid number of components are provided
-
partitionOf
@Nonnull static List<ActionRow> partitionOf(@Nonnull Collection<? extends ActionRowChildComponent> components) Partitions the providedcomponents
into a list of ActionRow instances.
This will split the provided components bygetMaxAllowed(Type)
()} and create homogeneously typed rows, meaning they will not have mixed component types.Example
List<ActionRowChildComponent> components = Arrays.asList( Button.primary("id1", "Hello"), Button.secondary("id2", "World"), SelectMenu.create("menu:id").build() ); List<ActionRow> partitioned = ActionRow.partition(components); // partitioned[0] = ActionRow(button, button) // partitioned[1] = ActionRow(selectMenu)
- Parameters:
components
- The components to partition- Returns:
List
ofActionRow
- Throws:
IllegalArgumentException
- If null is provided or there is no components
-
partitionOf
Partitions the providedcomponents
into a list of ActionRow instances.
This will split the provided components bygetMaxAllowed(Type)
and create homogeneously typed rows, meaning they will not have mixed component types.Example
List<ActionRowChildComponent> components = Arrays.asList( Button.primary("id1", "Hello"), Button.secondary("id2", "World"), SelectMenu.create("menu:id").build() ); List<ActionRow> partitioned = ActionRow.partition(components); // partitioned[0] = ActionRow(button, button) // partitioned[1] = ActionRow(selectMenu)
- Parameters:
components
- The components to partition- Returns:
List
ofActionRow
- Throws:
IllegalArgumentException
- If null is provided or there is no components
-
getMaxAllowed
How many of components of the provided type can be added to a singleActionRow
.- Returns:
- The maximum amount an action row can contain
-
withUniqueId
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 interfaceComponent
- Specified by:
withUniqueId
in interfaceContainerChildComponent
- Specified by:
withUniqueId
in interfaceIDisableable
- Specified by:
withUniqueId
in interfaceMessageTopLevelComponent
- Specified by:
withUniqueId
in interfaceModalTopLevelComponent
- Parameters:
uniqueId
- The new ID; must be higher or equal to 1- Returns:
- The new component
-
getComponents
Returns an unmodifiable list of the components contained in this action row.- Returns:
- Unmodifiable
List
ofActionRowChildComponentUnion
contained in this action row
-
getActionComponents
Returns an immutable list ofActionComponents
in this row.- Returns:
- Immutable
List
copy ofActionComponents
in this row
-
getButtons
Returns an immutable list ofButtons
in this row. -
isMessageCompatible
default boolean isMessageCompatible()Description copied from interface:Component
Whether this Component is compatible withMessages
.
If the component in question contains other components, this also checks every component inside it.- Specified by:
isMessageCompatible
in interfaceComponent
- Returns:
- True, if this Component (and its children) is compatible with messages.
-
isModalCompatible
default boolean isModalCompatible()Description copied from interface:Component
Whether this Component is compatible withModals
.
If the component in question contains other components, this also checks every component inside it.- Specified by:
isModalCompatible
in interfaceComponent
- Returns:
- True, if this Component (and its children) is compatible with modals.
-
replace
Description copied from interface:IReplaceable
Replaces and/or removes children components using the providedComponentReplacer
, and construct a new component from the result.- Specified by:
replace
in interfaceIReplaceable
- Parameters:
replacer
- TheComponentReplacer
to apply- Returns:
- The new, updated component
- See Also:
-
isDisabled
default boolean isDisabled()Description copied from interface:IDisableable
Whether this component is disabled.For layout components, this means all children are enabled.
When this returnsfalse
, this does not meanIDisableable.isEnabled()
istrue
! (for example, when one component is enabled and the other is disabled)You can use
IDisableable.asDisabled()
orIDisableable.asEnabled()
to create enabled/disabled instances.- Specified by:
isDisabled
in interfaceIDisableable
- Returns:
true
, if this component is disabled
-
isEnabled
default boolean isEnabled()Description copied from interface:IDisableable
Whether this component is enabled.For layout components, this means all children are enabled.
When this returnsfalse
, this does not meanIDisableable.isDisabled()
istrue
! (for example, when one component is enabled and the other is disabled)You can use
IDisableable.asDisabled()
orIDisableable.asEnabled()
to create enabled/disabled instances.- Specified by:
isEnabled
in interfaceIDisableable
- Returns:
true
if this component is enabled
-
withDisabled
Description copied from interface:IDisableable
Returns a new instance of this component in an enabled/disabled state.
For layout components, this enables/disables all the components it contains.- Specified by:
withDisabled
in interfaceIDisableable
- Returns:
- The new component in an enabled/disabled state
- See Also:
-
asDisabled
Description copied from interface:IDisableable
Returns a new instance of this component in a disabled state.
For layout components, this disables all the components it contains.- Specified by:
asDisabled
in interfaceIDisableable
- Returns:
- The new component in a disabled state
- See Also:
-
asEnabled
Description copied from interface:IDisableable
Returns a new instance of this component in an enabled state.
For layout components, this enables all the components it contains.- Specified by:
asEnabled
in interfaceIDisableable
- Returns:
- The new component in an enabled state
- See Also:
-