Interface Container
- All Superinterfaces:
Component,IDisableable,IReplaceable,MessageTopLevelComponent
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 ContainerReturns a new instance of this component in a disabled state.default ContainerReturns a new instance of this component in an enabled state.default ColorThe 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 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.booleanWhether this container is hidden until the user clicks on it.static Containerof(Collection<? extends ContainerChildComponent> components) Constructs a newContainerfrom the given components.static Containerof(ContainerChildComponent component, ContainerChildComponent... components) Constructs a newContainerfrom the given components.replace(ComponentReplacer replacer) Replaces and/or removes children components using the providedComponentReplacer, and construct a new component from the result.default ContainerwithAccentColor(Color accentColor) Creates a newContainerwith the specified accent color, which appears on the side.withAccentColor(Integer accentColor) Creates a newContainerwith the specified accent color, which appears on the side.withComponents(Collection<? extends ContainerChildComponent> components) Creates a newContainerwith the specified components.default ContainerwithComponents(ContainerChildComponent component, ContainerChildComponent... components) Creates a newContainerwith the specified components.default ContainerwithDisabled(boolean disabled) Returns a new instance of this component in an enabled/disabled state.withSpoiler(boolean spoiler) Creates a newContainerwith 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 newContainerfrom the given components.- Parameters:
components- The components to add- Returns:
- The new
Container - Throws:
IllegalArgumentException-- If
nullis provided - If one of the components is unknown
- If
-
of
@Nonnull static Container of(@Nonnull ContainerChildComponent component, @Nonnull ContainerChildComponent... components) Constructs a newContainerfrom the given components.- Parameters:
component- The first componentcomponents- Additional components to add- Returns:
- The new
Container - Throws:
IllegalArgumentException-- If
nullis provided - If one of the components is unknown
- If
-
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:
-
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 interfaceIDisableable- Specified by:
withUniqueIdin interfaceMessageTopLevelComponent- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-
withAccentColor
Creates a newContainerwith the specified accent color, which appears on the side.- Parameters:
accentColor- The new accent color, ornullto remove it- Returns:
- The new
Container
-
withAccentColor
Creates a newContainerwith the specified accent color, which appears on the side.
Note that thealpha componentwill be removed, making the color opaque.- Parameters:
accentColor- The new accent color, ornullto remove it- Returns:
- The new
Container
-
withSpoiler
Creates a newContainerwith 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 newContainerwith the specified components.- Parameters:
components- The new components- Returns:
- The new
Container - Throws:
IllegalArgumentException- If the provided components arenullor containsnull
-
withComponents
@Nonnull @CheckReturnValue default Container withComponents(@Nonnull ContainerChildComponent component, @Nonnull ContainerChildComponent... components) Creates a newContainerwith the specified components.- Parameters:
component- The first new componentcomponents- Additional new components- Returns:
- The new
Container - Throws:
IllegalArgumentException- If the provided components arenullor containsnull
-
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:
-
getComponents
Returns an immutable list with the components contained by this container.- Returns:
ListofContainerChildComponentUnionin this container
-
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
-
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:
trueif this is hidden by default,falseotherwise
-