Interface Section
- All Superinterfaces:
Component,ContainerChildComponent,IDisableable,IReplaceable,MessageTopLevelComponent
public interface Section
extends MessageTopLevelComponent, ContainerChildComponent, IReplaceable, IDisableable
Component which contains the main content on the left and an accessory on the right.
This can contain up to 3 SectionContentComponent.
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHow manySectionContentComponentcan be in this section. -
Method Summary
Modifier and TypeMethodDescriptiondefault SectionReturns a new instance of this component in a disabled state.default SectionReturns a new instance of this component in an enabled state.The accessory of this section.@Unmodifiable List<SectionContentComponentUnion> Returns an immutable list with the components contained by this section.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 Sectionof(SectionAccessoryComponent accessory, Collection<? extends SectionContentComponent> components) Constructs a newSectionfrom the given accessory and components.static Sectionof(SectionAccessoryComponent accessory, SectionContentComponent component, SectionContentComponent... components) Constructs a newSectionfrom the given accessory and components.replace(ComponentReplacer replacer) Replaces and/or removes children components using the providedComponentReplacer, and construct a new component from the result.withAccessory(SectionAccessoryComponent accessory) Creates a newSectionwith the specified accessory.withContentComponents(Collection<? extends SectionContentComponent> components) Creates a newSectionwith the specified content components.default SectionwithContentComponents(SectionContentComponent component, SectionContentComponent... components) Creates a newSectionwith the specified content components.default SectionwithDisabled(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
-
Field Details
-
MAX_COMPONENTS
static final int MAX_COMPONENTSHow manySectionContentComponentcan be in this section. (3)- See Also:
-
-
Method Details
-
of
@Nonnull static Section of(@Nonnull SectionAccessoryComponent accessory, @Nonnull Collection<? extends SectionContentComponent> components) Constructs a newSectionfrom the given accessory and components.- Parameters:
accessory- The accessory of this sectioncomponents- The components to add- Returns:
- The new
Section - Throws:
IllegalArgumentException-
-
of
@Nonnull static Section of(@Nonnull SectionAccessoryComponent accessory, @Nonnull SectionContentComponent component, @Nonnull SectionContentComponent... components) Constructs a newSectionfrom the given accessory and components.- Parameters:
accessory- The accessory of this sectioncomponent- The component to addcomponents- Additional components to add- Returns:
- The new
Section - Throws:
IllegalArgumentException-
-
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 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
-
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:
-
withContentComponents
@Nonnull @CheckReturnValue Section withContentComponents(@Nonnull Collection<? extends SectionContentComponent> components) Creates a newSectionwith the specified content components.- Parameters:
components- The new content components- Returns:
- The new
Section - Throws:
IllegalArgumentException- If the provided components arenullor containsnull
-
withContentComponents
@Nonnull @CheckReturnValue default Section withContentComponents(@Nonnull SectionContentComponent component, @Nonnull SectionContentComponent... components) Creates a newSectionwith the specified content components.- Parameters:
component- The first new content componentcomponents- Additional new content components- Returns:
- The new
Section - Throws:
IllegalArgumentException- If the provided components arenullor containsnull
-
withAccessory
Creates a newSectionwith the specified accessory.- Parameters:
accessory- The new accessory- Returns:
- The new
Section - Throws:
IllegalArgumentException- If the provided accessory isnull
-
getContentComponents
Returns an immutable list with the components contained by this section.- Returns:
ListofSectionContentComponentUnionin this section
-
getAccessory
The accessory of this section.- Returns:
- Accessory of this section
-
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
-