Interface ActionRow

All Superinterfaces:
Component, ContainerChildComponent, IDisableable, IReplaceable, MessageTopLevelComponent

One row of action components.
See Also:
  • Method Details

    • of

      @Nonnull static ActionRow of(@Nonnull Collection<? extends ActionRowChildComponent> components)
      Create one row of components.
      You cannot currently mix different types of components and each type has its own maximum defined by getMaxAllowed(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 of components.
      You cannot currently mix different types of components and each type has its own maximum defined by getMaxAllowed(Type).
      Parameters:
      component - The first component for this action row
      components - 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 provided components into a list of ActionRow instances.
      This will split the provided components by getMaxAllowed(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 of ActionRow
      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 provided components into a list of ActionRow instances.
      This will split the provided components by getMaxAllowed(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 partition
      components - Additional components to partition
      Returns:
      List of ActionRow
      Throws:
      IllegalArgumentException - If null is provided or there is no components
    • getMaxAllowed

      static int getMaxAllowed(@Nonnull Component.Type type)
      How many of components of the provided type can be added to a single ActionRow.
      Returns:
      The maximum amount an action row can contain
    • withUniqueId

      @Nonnull @CheckReturnValue ActionRow 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 ContainerChildComponent
      Specified by:
      withUniqueId in interface IDisableable
      Specified by:
      withUniqueId in interface MessageTopLevelComponent
      Parameters:
      uniqueId - The new ID; must be higher or equal to 1
      Returns:
      The new component
    • getComponents

      @Nonnull @Unmodifiable List<ActionRowChildComponentUnion> getComponents()
      Returns an unmodifiable list of the components contained in this action row.
      Returns:
      Unmodifiable List of ActionRowChildComponentUnion contained in this action row
    • getActionComponents

      @Nonnull default @Unmodifiable List<ActionComponent> getActionComponents()
      Returns an immutable list of ActionComponents in this row.
      Returns:
      Immutable List copy of ActionComponents in this row
    • getButtons

      @Nonnull default @Unmodifiable List<Button> getButtons()
      Returns an immutable list of Buttons in this row.
      Returns:
      Immutable List of Buttons
    • isMessageCompatible

      default boolean isMessageCompatible()
      Description copied from interface: Component
      Whether this Component is compatible with Messages.
      If the component in question contains other components, this also checks every component inside it.
      Specified by:
      isMessageCompatible in interface Component
      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 with Modals.
      If the component in question contains other components, this also checks every component inside it.
      Specified by:
      isModalCompatible in interface Component
      Returns:
      True, if this Component (and its children) is compatible with modals.
    • replace

      @Nonnull @CheckReturnValue ActionRow replace(@Nonnull ComponentReplacer replacer)
      Description copied from interface: IReplaceable
      Replaces and/or removes children components using the provided ComponentReplacer, and construct a new component from the result.
      Specified by:
      replace in interface IReplaceable
      Parameters:
      replacer - The ComponentReplacer 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 returns false, this does not mean IDisableable.isEnabled() is true! (for example, when one component is enabled and the other is disabled)

      You can use IDisableable.asDisabled() or IDisableable.asEnabled() to create enabled/disabled instances.

      Specified by:
      isDisabled in interface IDisableable
      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 returns false, this does not mean IDisableable.isDisabled() is true! (for example, when one component is enabled and the other is disabled)

      You can use IDisableable.asDisabled() or IDisableable.asEnabled() to create enabled/disabled instances.

      Specified by:
      isEnabled in interface IDisableable
      Returns:
      true if this component is enabled
    • withDisabled

      @Nonnull @CheckReturnValue default ActionRow withDisabled(boolean disabled)
      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 interface IDisableable
      Returns:
      The new component in an enabled/disabled state
      See Also:
    • asDisabled

      @Nonnull default ActionRow 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 interface IDisableable
      Returns:
      The new component in a disabled state
      See Also:
    • asEnabled

      @Nonnull default ActionRow 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 interface IDisableable
      Returns:
      The new component in an enabled state
      See Also:
    • withComponents

      @Nonnull @CheckReturnValue ActionRow withComponents(@Nonnull Collection<? extends ActionRowChildComponent> components)
      Creates a new ActionRow with the specified components.
      Parameters:
      components - The new components
      Returns:
      The new ActionRow
      Throws:
      IllegalArgumentException - If the provided components are null or contains null
    • withComponents

      @Nonnull @CheckReturnValue default ActionRow withComponents(@Nonnull ActionRowChildComponent component, @Nonnull ActionRowChildComponent... components)
      Creates a new ActionRow with the specified components.
      Parameters:
      component - The first new component
      components - Additional new components
      Returns:
      The new ActionRow
      Throws:
      IllegalArgumentException - If the provided components are null or contains null