Interface LabelChildComponentUnion

All Superinterfaces:
Component, IComponentUnion, LabelChildComponent

public interface LabelChildComponentUnion extends LabelChildComponent, IComponentUnion
Represents a union of LabelChildComponent that can be one of:
  • Method Details

    • asTextInput

      @Nonnull TextInput asTextInput()
      Casts this union to a TextInput. This method exists for developer discoverability.

      Note: This is effectively equivalent to using the cast operator:

      
       //These are the same!
       TextInput input = union.asTextInput();
       TextInput input2 = (TextInput) union;
       
      You can use Component.getType() to see if the component is of type Component.Type.TEXT_INPUT to 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 a TextInput.
    • asStringSelectMenu

      @Nonnull StringSelectMenu asStringSelectMenu()
      Casts this union to a StringSelectMenu. This method exists for developer discoverability.

      Note: This is effectively equivalent to using the cast operator:

      
       //These are the same!
       StringSelectMenu menu = union.asStringSelectMenu();
       StringSelectMenu menu2 = (StringSelectMenu) union;
       
      You can use Component.getType() to see if the component is of type Component.Type.STRING_SELECT to 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 a StringSelectMenu.
    • withUniqueId

      @Nonnull LabelChildComponentUnion withUniqueId(int uniqueId)
      Description copied from interface: Component
      Creates 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:
      withUniqueId in interface Component
      Specified by:
      withUniqueId in interface IComponentUnion
      Specified by:
      withUniqueId in interface LabelChildComponent
      Parameters:
      uniqueId - The new ID; must be higher or equal to 1
      Returns:
      The new component