Interface SectionAccessoryComponentUnion
- All Superinterfaces:
Component,IComponentUnion,SectionAccessoryComponent
Represents a union of
SectionAccessoryComponents that can be one of:
ButtonThumbnailUnknownComponent, detectable viaIComponentUnion.isUnknownComponent()
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.components.Component
Component.Type -
Method Summary
Modifier and TypeMethodDescriptionasButton()Casts this union to aButton.Casts this union to aThumbnail.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
-
asButton
Casts this union to aButton. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! Button button = union.asButton(); Button button2 = (Button) union;Component.getType()to see if the component is of typeComponent.Type.BUTTONto validate whether you can call this method in addition to normal instanceof checks:component instanceof Button- Returns:
- The component as a
Button - Throws:
IllegalStateException- If the component represented by this union is not actually aButton.
-
asThumbnail
Casts this union to aThumbnail. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! Thumbnail thumbnail = union.asThumbnail(); Thumbnail thumbnail2 = (Thumbnail) union;Component.getType()to see if the component is of typeComponent.Type.THUMBNAILto validate whether you can call this method in addition to normal instanceof checks:component instanceof Thumbnail- Returns:
- The component as a
Thumbnail - Throws:
IllegalStateException- If the component represented by this union is not actually aThumbnail.
-
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 interfaceIComponentUnion- Specified by:
withUniqueIdin interfaceSectionAccessoryComponent- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-