Interface LabelChildComponentUnion
- All Superinterfaces:
Component, IComponentUnion, LabelChildComponent
Represents a union of
LabelChildComponent that can be one of:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Component
Component.Type -
Method Summary
Modifier and TypeMethodDescriptionCasts this union to aAttachmentUpload.Casts this union to aEntitySelectMenu.Casts this union to aStringSelectMenu.Casts this union to aTextInput.withUniqueId(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from interface Component
getType, getUniqueId, isMessageCompatible, isModalCompatibleMethods inherited from interface IComponentUnion
isUnknownComponent
-
Method Details
-
asTextInput
Casts this union to aTextInput. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! TextInput input = union.asTextInput(); TextInput input2 = (TextInput) union;Component.getType()to see if the component is of typeComponent.Type.TEXT_INPUTto validate whether you can call this method in addition to normal instanceof checks:component instanceof TextInput- Returns:
- The component as a
TextInput - Throws:
IllegalStateException- If the component represented by this union is not actually aTextInput.
-
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 menu = union.asStringSelectMenu(); StringSelectMenu menu2 = (StringSelectMenu) 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 aEntitySelectMenu. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! EntitySelectMenu menu = union.asEntitySelectMenu(); EntitySelectMenu menu2 = (EntitySelectMenu) union;Component.getType()to see if the component is one of: to 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.
-
asAttachmentUpload
Casts this union to aAttachmentUpload. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! AttachmentUpload menu = union.asAttachmentUpload(); AttachmentUpload menu2 = (AttachmentUpload) union;Component.getType()to see if the component is of typeComponent.Type.FILE_UPLOADto validate whether you can call this method in addition to normal instanceof checks:component instanceof AttachmentUpload- Returns:
- The component as a
AttachmentUpload - Throws:
IllegalStateException- If the component represented by this union is not actually aAttachmentUpload.
-
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 interfaceLabelChildComponent- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-