Interface Attachment

    • Method Detail

      • getFileName

        java.lang.String getFileName()
        Gets the file name of the attachment.
        Returns:
        The file name of the attachment.
      • getDescription

        java.util.Optional<java.lang.String> getDescription()
        Gets the description of the attachment.
        Returns:
        The description of the attachment.
      • getSize

        int getSize()
        Gets the size of the attachment in bytes.
        Returns:
        The size of the attachment in bytes.
      • getUrl

        java.net.URL getUrl()
        Gets the url of the attachment.
        Returns:
        The url of the attachment.
      • getProxyUrl

        java.net.URL getProxyUrl()
        Gets the proxy url of the attachment.
        Returns:
        The proxy url of the attachment.
      • isImage

        default boolean isImage()
        Checks if the attachment is an image.
        Returns:
        Whether the attachment is an image or not.
      • getHeight

        java.util.Optional<java.lang.Integer> getHeight()
        Gets the height of the attachment, if it's an image.
        Returns:
        The height of the attachment.
      • getWidth

        java.util.Optional<java.lang.Integer> getWidth()
        Gets the width of the attachment, if it's an image.
        Returns:
        The width of the attachment.
      • isEphemeral

        java.util.Optional<java.lang.Boolean> isEphemeral()
        Gets whether this attachment is ephemeral. Ephemeral attachments will automatically be removed after a set period of time and attachments on messages are guaranteed to be available as long as the message itself exists.
        Returns:
        True if the attachment is ephemeral.
      • downloadAsInputStream

        @Deprecated
        default java.io.InputStream downloadAsInputStream()
                                                   throws java.io.IOException
        Deprecated.
        Use asInputStream() instead.
        Downloads the attachment as an input stream.
        Returns:
        The attachment as an input stream.
        Throws:
        java.io.IOException - If an IO error occurs.
      • downloadAsByteArray

        @Deprecated
        default java.util.concurrent.CompletableFuture<byte[]> downloadAsByteArray()
        Deprecated.
        Use asByteArray() instead.
        Downloads the attachment as a byte array.
        Returns:
        The attachment as a byte array.
      • downloadAsImage

        @Deprecated
        default java.util.concurrent.CompletableFuture<java.awt.image.BufferedImage> downloadAsImage()
        Deprecated.
        Use asImage() instead.
        Downloads the attachment as an image.
        Returns:
        The attachment as an image. Only present, if the attachment is an image.
        Throws:
        java.lang.IllegalStateException - If the attachment is not an image.
      • asInputStream

        java.io.InputStream asInputStream()
                                   throws java.io.IOException
        Downloads the attachment as an input stream.
        Returns:
        The attachment as an input stream.
        Throws:
        java.io.IOException - If an IO error occurs.
      • asByteArray

        java.util.concurrent.CompletableFuture<byte[]> asByteArray()
        Downloads the attachment as a byte array.
        Returns:
        The attachment as a byte array.
      • asImage

        java.util.concurrent.CompletableFuture<java.awt.image.BufferedImage> asImage()
        Downloads the attachment as an image.
        Returns:
        The attachment as an image. Only present, if the attachment is an image.
        Throws:
        java.lang.IllegalStateException - If the attachment is not an image.
      • isSpoiler

        default boolean isSpoiler()
        Checks whether the attachment is marked as a spoiler.

        Discord encodes the information on whether a file is considered a spoiler in the file name. Any file whose filename starts with SPOILER_ is considered a spoiler.

        Returns:
        The spoiler status.