Interface Container
- All Superinterfaces:
Component
,IDisableable
,IReplaceable
,MessageTopLevelComponent
- All Known Implementing Classes:
ContainerImpl
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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.components.Component
Component.Type
-
Method Summary
Modifier and TypeMethodDescriptiondefault Container
Returns a new instance of this component in a disabled state.default Container
Returns a new instance of this component in an enabled state.default Color
The color of the stripe/border on the side of the container.The raw RGB color value for the stripe/border on the side of the container.@Unmodifiable List
<ContainerChildComponentUnion> Returns an immutable list with the components contained by this container.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
.boolean
Whether this container is hidden until the user clicks on it.static Container
of
(Collection<? extends ContainerChildComponent> components) Constructs a newContainer
from the given components.static Container
of
(ContainerChildComponent component, ContainerChildComponent... components) Constructs a newContainer
from the given components.replace
(ComponentReplacer replacer) Replaces and/or removes children components using the providedComponentReplacer
, and construct a new component from the result.default Container
withAccentColor
(Color accentColor) Creates a newContainer
with the specified accent color, which appears on the side.withAccentColor
(Integer accentColor) Creates a newContainer
with the specified accent color, which appears on the side.default Container
withDisabled
(boolean disabled) Returns a new instance of this component in an enabled/disabled state.withSpoiler
(boolean spoiler) Creates a newContainer
with the specified spoiler status.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
Constructs a newContainer
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
- If
-
of
@Nonnull static Container of(@Nonnull ContainerChildComponent component, @Nonnull ContainerChildComponent... components) Constructs a newContainer
from the given components.- Parameters:
component
- The first componentcomponents
- Additional components to add- Returns:
- The new
Container
- Throws:
IllegalArgumentException
-- If
null
is provided - If one of the components is unknown
- If
-
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:
-
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 interfaceIDisableable
- Specified by:
withUniqueId
in interfaceMessageTopLevelComponent
- Parameters:
uniqueId
- The new ID; must be higher or equal to 1- Returns:
- The new component
-
withAccentColor
Creates a newContainer
with the specified accent color, which appears on the side.- Parameters:
accentColor
- The new accent color, ornull
to remove it- Returns:
- The new
Container
-
withAccentColor
Creates a newContainer
with the specified accent color, which appears on the side.
Note that thealpha component
will be removed, making the color opaque.- Parameters:
accentColor
- The new accent color, ornull
to remove it- Returns:
- The new
Container
-
withSpoiler
Creates a newContainer
with the specified spoiler status.
Spoilers are hidden until the user clicks on it.- Parameters:
spoiler
- The new spoiler status- Returns:
- The new
Container
-
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:
-
getComponents
Returns an immutable list with the components contained by this container.- Returns:
List
ofContainerChildComponentUnion
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 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
-
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
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
-