Interface ActionRowChildComponentUnion
- All Superinterfaces:
ActionRowChildComponent,Component,IComponentUnion
Represents a union of
ActionRowChildComponents 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 TypeMethodDescriptionasButton()Casts this union to aButton.Casts this union to aStringSelectMenu.Casts this union to aStringSelectMenu.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.
-
asStringSelectMenu
Casts this union to aStringSelectMenu. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! StringSelectMenu stringSelectMenu = union.asStringSelectMenu(); StringSelectMenu stringSelectMenu2 = (Button) union;Component.getType()to see if the component is of typeComponent.Type.STRING_SELECTto validate whether you can call this method in addition to normal instanceof checks:component instanceof StringSelectMenu- Returns:
- The component as a
StringSelectMenu - Throws:
IllegalStateException- If the component represented by this union is not actually aStringSelectMenu.
-
asEntitySelectMenu
Casts this union to aStringSelectMenu. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! EntitySelectMenu entitySelectMenu = union.asEntitySelectMenu(); EntitySelectMenu entitySelectMenu2 = (Button) union;Component.getType()to see if the component is of typeComponent.Type.MENTIONABLE_SELECTto validate whether you can call this method in addition to normal instanceof checks:component instanceof EntitySelectMenu- Returns:
- The component as a
EntitySelectMenu - Throws:
IllegalStateException- If the component represented by this union is not actually aEntitySelectMenu.
-
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 interfaceActionRowChildComponent- Specified by:
withUniqueIdin interfaceComponent- Specified by:
withUniqueIdin interfaceIComponentUnion- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-