Class AttachmentUpload.Builder

java.lang.Object
net.dv8tion.jda.api.components.attachmentupload.AttachmentUpload.Builder
Enclosing interface:
AttachmentUpload

public static class AttachmentUpload.Builder extends Object
Builder for AttachmentUploads.
  • Method Details

    • setUniqueId

      @Nonnull public AttachmentUpload.Builder setUniqueId(int uniqueId)
    • setCustomId

      @Nonnull public AttachmentUpload.Builder setCustomId(@Nonnull String customId)
      Changes the custom ID.
      This ID can be used to pass data, then read in an interaction.
      Parameters:
      customId - The new custom ID
      Returns:
      The same instance, for chaining purposes
      Throws:
      IllegalArgumentException - If customId is null, blank, or longer than 100 characters
    • setMinValues

      @Nonnull public AttachmentUpload.Builder setMinValues(int minValues)
      Changes the minimum amount of attachments the user has to send.
      Default: 1
      Parameters:
      minValues - The new minimum amount of attachments the user has to send, must be >= 0 and less than 10
      Returns:
      The same instance, for chaining purposes
      Throws:
      IllegalArgumentException - If minValues is negative or larger than 10
    • setMaxValues

      @Nonnull public AttachmentUpload.Builder setMaxValues(int maxValues)
      Changes the maximum amount of attachments the user can send.
      Default: 1
      Parameters:
      maxValues - The new maximum amount of attachments the user can send, must be positive and less than 10
      Returns:
      The same instance, for chaining purposes
      Throws:
      IllegalArgumentException - If maxValues is negative, zero, or larger than 10
    • setRequiredRange

      @Nonnull public AttachmentUpload.Builder setRequiredRange(int min, int max)
      Changes the amounts of attachments the user can send.
      Default: [1 ; 1]
      Parameters:
      min - The new minimum amount of attachments the user must send, must be >= 0 and less than 10
      max - The new maximum amount of attachments the user can send, must be positive and less than 10
      Returns:
      The same instance, for chaining purposes
      Throws:
      IllegalArgumentException -
      • If min is negative or larger than 10
      • If max is negative, zero, or larger than 10
    • setRequired

      @Nonnull public AttachmentUpload.Builder setRequired(boolean required)
      Changes whether the user must upload files.
      Default: true

      This attribute is completely separate from the value range, for example you can have an optional AttachmentUpload with the range set to [2 ; 2], meaning you accept either 0 attachments, or 2.

      Parameters:
      required - The new required status
      Returns:
      The same instance, for chaining purposes
    • getUniqueId

      public int getUniqueId()
      The unique, numeric identifier of this component.
      Can be set manually or automatically assigned by Discord (starting from 1). If it has not been assigned yet, this will return -1.
      Returns:
      The unique identifier of this component, or -1 if not assigned yet
    • getCustomId

      @Nonnull public String getCustomId()
      Returns the unique custom ID, this can be used to pass data, then read in an interaction.
      Returns:
      The custom ID
    • getMinValues

      public int getMinValues()
      The minimum amount of attachments the user must send.
      Returns:
      Minimum amount of attachments the user must send
    • getMaxValues

      public int getMaxValues()
      The maximum amount of attachments the user can send.
      Returns:
      Maximum amount of attachments the user can send
    • isRequired

      public boolean isRequired()
      Whether the user must send attachments.

      This attribute is completely separate from the value range, for example you can have an optional AttachmentUpload with the range set to [2 ; 2], meaning you accept either 0 attachments, or 2.

      Returns:
      true if files must be uploaded, false if not
    • build

      @Nonnull public AttachmentUpload build()
      Builds a new AttachmentUpload.
      Returns:
      The new AttachmentUpload
      Throws:
      IllegalArgumentException - If min values is larger than max values