Interface Container

All Superinterfaces:
Component, IDisableable, IReplaceable, MessageTopLevelComponent

public interface Container extends MessageTopLevelComponent, IReplaceable, IDisableable
Component which groups components vertically, you can specify an accent color, similar to embeds, and mark the container as a spoiler.

Requirements: Components V2 needs to be enabled!

See Also:
  • Method Details

    • of

      @Nonnull static Container of(@Nonnull Collection<? extends ContainerChildComponent> components)
      Constructs a new Container from the given components.
      Parameters:
      components - The components to add
      Returns:
      The new Container
      Throws:
      IllegalArgumentException -
      • If null is provided
      • If one of the components is unknown
    • of

      @Nonnull static Container of(@Nonnull ContainerChildComponent component, @Nonnull ContainerChildComponent... components)
      Constructs a new Container from the given components.
      Parameters:
      component - The first component
      components - Additional components to add
      Returns:
      The new Container
      Throws:
      IllegalArgumentException -
      • If null is provided
      • If one of the components is unknown
    • 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 Container 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:
    • withUniqueId

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

      @Nonnull @CheckReturnValue Container withAccentColor(@Nullable Integer accentColor)
      Creates a new Container with the specified accent color, which appears on the side.
      Parameters:
      accentColor - The new accent color, or null to remove it
      Returns:
      The new Container
    • withAccentColor

      @Nonnull @CheckReturnValue default Container withAccentColor(@Nullable Color accentColor)
      Creates a new Container with the specified accent color, which appears on the side.
      Note that the alpha component will be removed, making the color opaque.
      Parameters:
      accentColor - The new accent color, or null to remove it
      Returns:
      The new Container
    • withSpoiler

      @Nonnull @CheckReturnValue Container withSpoiler(boolean spoiler)
      Creates a new Container with the specified spoiler status.
      Spoilers are hidden until the user clicks on it.
      Parameters:
      spoiler - The new spoiler status
      Returns:
      The new Container
    • withComponents

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

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

      @Nonnull @CheckReturnValue default Container 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 @CheckReturnValue default Container 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 @CheckReturnValue default Container 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:
    • getComponents

      @Nonnull @Unmodifiable List<ContainerChildComponentUnion> getComponents()
      Returns an immutable list with the components contained by this container.
      Returns:
      List of ContainerChildComponentUnion in this container
    • 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
    • getAccentColor

      @Nullable default Color getAccentColor()
      The color of the stripe/border on the side of the container.
      If no accent color has been set, this will return null.
      Returns:
      Possibly-null Color.
    • getAccentColorRaw

      @Nullable Integer getAccentColorRaw()
      The raw RGB color value for the stripe/border on the side of the container.
      If no accent color has been set, this will return null.
      Returns:
      The raw RGB color value or null.
    • isSpoiler

      boolean isSpoiler()
      Whether this container is hidden until the user clicks on it.
      Returns:
      true if this is hidden by default, false otherwise