Interface ActionRowChildComponentUnion

All Superinterfaces:
ActionRowChildComponent, Component, IComponentUnion
All Known Implementing Classes:
ButtonImpl, EntitySelectMenuImpl, SelectMenuImpl, StringSelectMenuImpl, TextInputImpl, UnknownComponentImpl

public interface ActionRowChildComponentUnion extends ActionRowChildComponent, IComponentUnion
  • Method Details

    • asButton

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

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

      
       //These are the same!
       Button button = union.asButton();
       Button button2 = (Button) union;
       
      You can use Component.getType() to see if the component is of type Component.Type.BUTTON to 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 a Button.
    • 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 stringSelectMenu = union.asStringSelectMenu();
       StringSelectMenu stringSelectMenu2 = (Button) 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.
    • asEntitySelectMenu

      @Nonnull EntitySelectMenu asEntitySelectMenu()
      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!
       EntitySelectMenu entitySelectMenu = union.asEntitySelectMenu();
       EntitySelectMenu entitySelectMenu2 = (Button) union;
       
      You can use Component.getType() to see if the component is of type Component.Type.MENTIONABLE_SELECT 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 a EntitySelectMenu.
    • withUniqueId

      @Nonnull ActionRowChildComponentUnion 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 ActionRowChildComponent
      Specified by:
      withUniqueId in interface Component
      Specified by:
      withUniqueId in interface IComponentUnion
      Parameters:
      uniqueId - The new ID; must be higher or equal to 1
      Returns:
      The new component