Interface ContainerChildComponentUnion
- All Superinterfaces:
Component,ContainerChildComponent,IComponentUnion
Represents a union of
ContainerChildComponents that can be one of:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.components.Component
Component.Type -
Method Summary
Modifier and TypeMethodDescriptionCasts this union to aActionRow.Casts this union to aFileDisplay.Casts this union to aMediaGallery.Casts this union to aSection.Casts this union to aSeparator.Casts this union to aTextDisplay.withUniqueId(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from interface net.dv8tion.jda.api.components.Component
getType, getUniqueId, isMessageCompatible, isModalCompatibleMethods inherited from interface net.dv8tion.jda.api.components.IComponentUnion
isUnknownComponent
-
Method Details
-
asActionRow
Casts this union to aActionRow. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! ActionRow row = union.asActionRow(); ActionRow row2 = (ActionRow) union;Component.getType()to see if the component is of typeComponent.Type.ACTION_ROWto validate whether you can call this method in addition to normal instanceof checks:component instanceof ActionRow- Returns:
- The component as a
ActionRow - Throws:
IllegalStateException- If the component represented by this union is not actually aActionRow.
-
asSection
Casts this union to aSection. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! Section section = union.asSection(); Section section2 = (Section) union;Component.getType()to see if the component is of typeComponent.Type.SECTIONto validate whether you can call this method in addition to normal instanceof checks:component instanceof Section- Returns:
- The component as a
Section - Throws:
IllegalStateException- If the component represented by this union is not actually aSection.
-
asTextDisplay
Casts this union to aTextDisplay. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! TextDisplay textDisplay = union.asTextDisplay(); TextDisplay textDisplay2 = (TextDisplay) union;Component.getType()to see if the component is of typeComponent.Type.TEXT_DISPLAYto validate whether you can call this method in addition to normal instanceof checks:component instanceof TextDisplay- Returns:
- The component as a
TextDisplay - Throws:
IllegalStateException- If the component represented by this union is not actually aTextDisplay.
-
asMediaGallery
Casts this union to aMediaGallery. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! MediaGallery mediaGallery = union.asMediaGallery(); MediaGallery mediaGallery2 = (MediaGallery) union;Component.getType()to see if the component is of typeComponent.Type.MEDIA_GALLERYto validate whether you can call this method in addition to normal instanceof checks:component instanceof MediaGallery- Returns:
- The component as a
MediaGallery - Throws:
IllegalStateException- If the component represented by this union is not actually aMediaGallery.
-
asSeparator
Casts this union to aSeparator. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! Separator separator = union.asSeparator(); Separator separator2 = (Separator) union;Component.getType()to see if the component is of typeComponent.Type.SEPARATORto validate whether you can call this method in addition to normal instanceof checks:component instanceof Separator- Returns:
- The component as a
Separator - Throws:
IllegalStateException- If the component represented by this union is not actually aSeparator.
-
asFileDisplay
Casts this union to aFileDisplay. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! FileDisplay fileDisplay = union.asFileDisplay(); FileDisplay fileDisplay2 = (FileDisplay) union;Component.getType()to see if the component is of typeComponent.Type.FILE_DISPLAYto validate whether you can call this method in addition to normal instanceof checks:component instanceof FileDisplay- Returns:
- The component as a
FileDisplay - Throws:
IllegalStateException- If the component represented by this union is not actually aFileDisplay.
-
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 interfaceIComponentUnion- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-