Interface ActionRow
- All Superinterfaces:
Component,ContainerChildComponent,IDisableable,IReplaceable,MessageTopLevelComponent
public interface ActionRow
extends MessageTopLevelComponent, 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 ActionRowReturns a new instance of this component in a disabled state.default ActionRowReturns a new instance of this component in an enabled state.default @Unmodifiable List<ActionComponent> Returns an immutable list ofActionComponentsin this row.Returns an immutable list ofButtonsin this row.@Unmodifiable List<ActionRowChildComponentUnion> Returns an unmodifiable list of the components contained in this action row.static intgetMaxAllowed(Component.Type type) How many of components of the provided type can be added to a singleActionRow.default booleanWhether this component is disabled.default booleanWhether this component is enabled.default booleanWhether this Component is compatible withMessages.default booleanWhether this Component is compatible withModals.static ActionRowof(Collection<? extends ActionRowChildComponent> components) Create one row ofcomponents.static ActionRowof(ActionRowChildComponent component, ActionRowChildComponent... components) Create one row ofcomponents.partitionOf(Collection<? extends ActionRowChildComponent> components) Partitions the providedcomponentsinto a list of ActionRow instances.partitionOf(ActionRowChildComponent component, ActionRowChildComponent... components) Partitions the providedcomponentsinto 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.withComponents(Collection<? extends ActionRowChildComponent> components) Creates a newActionRowwith the specified components.default ActionRowwithComponents(ActionRowChildComponent component, ActionRowChildComponent... components) Creates a newActionRowwith the specified components.default ActionRowwithDisabled(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 bygetMaxAllowed(Type).- 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
@Nonnull static ActionRow of(@Nonnull ActionRowChildComponent component, @Nonnull ActionRowChildComponent... components) Create one row ofcomponents.
You cannot currently mix different types of components and each type has its own maximum defined bygetMaxAllowed(Type).- Parameters:
component- The first component for this action rowcomponents- Additional 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 providedcomponentsinto 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:
ListofActionRow- Throws:
IllegalArgumentException- If null is provided or there is no components
-
partitionOf
@Nonnull static List<ActionRow> partitionOf(@Nonnull ActionRowChildComponent component, @Nonnull ActionRowChildComponent... components) Partitions the providedcomponentsinto 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:
component- The first component to partitioncomponents- Additional components to partition- Returns:
ListofActionRow- 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: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 interfaceContainerChildComponent- Specified by:
withUniqueIdin interfaceIDisableable- Specified by:
withUniqueIdin interfaceMessageTopLevelComponent- 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
ListofActionRowChildComponentUnioncontained in this action row
-
getActionComponents
Returns an immutable list ofActionComponentsin this row.- Returns:
- Immutable
Listcopy ofActionComponentsin this row
-
getButtons
Returns an immutable list ofButtonsin this row. -
isMessageCompatible
default boolean isMessageCompatible()Description copied from interface:ComponentWhether this Component is compatible withMessages.
If the component in question contains other components, this also checks every component inside it.- Specified by:
isMessageCompatiblein interfaceComponent- Returns:
- True, if this Component (and its children) is compatible with messages.
-
isModalCompatible
default boolean isModalCompatible()Description copied from interface:ComponentWhether this Component is compatible withModals.
If the component in question contains other components, this also checks every component inside it.- Specified by:
isModalCompatiblein interfaceComponent- Returns:
- True, if this Component (and its children) is compatible with modals.
-
replace
Description copied from interface:IReplaceableReplaces and/or removes children components using the providedComponentReplacer, and construct a new component from the result.- Specified by:
replacein interfaceIReplaceable- Parameters:
replacer- TheComponentReplacerto apply- Returns:
- The new, updated component
- See Also:
-
isDisabled
default boolean isDisabled()Description copied from interface:IDisableableWhether 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:
isDisabledin interfaceIDisableable- Returns:
true, if this component is disabled
-
isEnabled
default boolean isEnabled()Description copied from interface:IDisableableWhether 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:
isEnabledin interfaceIDisableable- Returns:
trueif this component is enabled
-
withDisabled
Description copied from interface:IDisableableReturns a new instance of this component in an enabled/disabled state.
For layout components, this enables/disables all the components it contains.- Specified by:
withDisabledin interfaceIDisableable- Returns:
- The new component in an enabled/disabled state
- See Also:
-
asDisabled
Description copied from interface:IDisableableReturns a new instance of this component in a disabled state.
For layout components, this disables all the components it contains.- Specified by:
asDisabledin interfaceIDisableable- Returns:
- The new component in a disabled state
- See Also:
-
asEnabled
Description copied from interface:IDisableableReturns a new instance of this component in an enabled state.
For layout components, this enables all the components it contains.- Specified by:
asEnabledin interfaceIDisableable- Returns:
- The new component in an enabled state
- See Also:
-
withComponents
@Nonnull @CheckReturnValue ActionRow withComponents(@Nonnull Collection<? extends ActionRowChildComponent> components) Creates a newActionRowwith the specified components.- Parameters:
components- The new components- Returns:
- The new
ActionRow - Throws:
IllegalArgumentException- If the provided components arenullor containsnull
-
withComponents
@Nonnull @CheckReturnValue default ActionRow withComponents(@Nonnull ActionRowChildComponent component, @Nonnull ActionRowChildComponent... components) Creates a newActionRowwith the specified components.- Parameters:
component- The first new componentcomponents- Additional new components- Returns:
- The new
ActionRow - Throws:
IllegalArgumentException- If the provided components arenullor containsnull
-