Class FileType

java.lang.Object
net.dv8tion.jda.api.interactions.FileType

public final class FileType extends Object
Represents a type of file, you can use presets such as IMAGE, or specify an extension using ofExtension(String).

Remember that this only checks the extension, Discord does not check for any file signature/MIME type, and thus does not guarantee receiving a valid file.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final FileType
    Matches any audio supported by the Discord client.
    static final FileType
    Matches any image supported by the Discord client.
    static final FileType
    Matches any video supported by the Discord client.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    The raw value of this file type.
    int
     
    boolean
    Whether this file type accepts all audio formats supported by Discord.
    boolean
    Whether this file type accepts all image formats supported by Discord.
    boolean
    Whether this file type accepts all video formats supported by Discord.
    static FileType
    ofExtension(String extension)
    Creates a FileType matching the provided extension.
     

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • IMAGE

      public static final FileType IMAGE
      Matches any image supported by the Discord client.
    • VIDEO

      public static final FileType VIDEO
      Matches any video supported by the Discord client.
    • AUDIO

      public static final FileType AUDIO
      Matches any audio supported by the Discord client.
  • Constructor Details

    • FileType

      @Internal public FileType(String value)
  • Method Details

    • ofExtension

      @Nonnull public static FileType ofExtension(@Nonnull String extension)
      Creates a FileType matching the provided extension.
      Parameters:
      extension - The extension to match against.
      Returns:
      The new FileType
      Throws:
      IllegalArgumentException -
      • If the extension is null or empty
      • If the extension does not match [\w\-.]+ (latin letters, digits, dashes or dots)
    • isImage

      public boolean isImage()
      Whether this file type accepts all image formats supported by Discord.
      Returns:
      true if this file type accepts all image formats supported by Discord, false if not
    • isVideo

      public boolean isVideo()
      Whether this file type accepts all video formats supported by Discord.
      Returns:
      true if this file type accepts all video formats supported by Discord, false if not
    • isAudio

      public boolean isAudio()
      Whether this file type accepts all audio formats supported by Discord.
      Returns:
      true if this file type accepts all audio formats supported by Discord, false if not
    • getValue

      @Nonnull public String getValue()
      The raw value of this file type.
      Returns:
      The raw value
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object