Interface SectionAccessoryComponentUnion

All Superinterfaces:
Component, IComponentUnion, SectionAccessoryComponent
All Known Implementing Classes:
ButtonImpl, ThumbnailFileUpload, ThumbnailImpl, UnknownComponentImpl

public interface SectionAccessoryComponentUnion extends SectionAccessoryComponent, IComponentUnion
Represents a union of SectionAccessoryComponents that can be one of:
  • 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.
    • asThumbnail

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

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

      
       //These are the same!
       Thumbnail thumbnail = union.asThumbnail();
       Thumbnail thumbnail2 = (Thumbnail) union;
       
      You can use Component.getType() to see if the component is of type Component.Type.THUMBNAIL to 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 a Thumbnail.
    • withUniqueId

      @Nonnull SectionAccessoryComponentUnion 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 SectionAccessoryComponent
      Parameters:
      uniqueId - The new ID; must be higher or equal to 1
      Returns:
      The new component