Package org.javacord.api.entity.message
Interface MessageAttachment
-
- All Superinterfaces:
DiscordEntity
public interface MessageAttachment extends DiscordEntity
This class represents a message attachment.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CompletableFuture<byte[]>downloadAsByteArray()Gets the attachment as byte array.CompletableFuture<BufferedImage>downloadAsImage()Downloads the attachment as image.StringgetFileName()Gets the file name of the attachment.Optional<Integer>getHeight()Gets the height of the attachment, if it's an image.MessagegetMessage()Gets the message of the attachment.URLgetProxyUrl()Gets the proxy url of the attachment.intgetSize()Gets the size of the attachment in bytes.URLgetUrl()Gets the url of the attachment.Optional<Integer>getWidth()Gets the width of the attachment, if it's an image.default booleanisImage()Checks if the attachment is an image.-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getApi, getCreationTimestamp, getCreationTimestamp, getId, getIdAsString
-
-
-
-
Method Detail
-
getMessage
Message getMessage()
Gets the message of the attachment.- Returns:
- The message of the attachment.
-
getFileName
String getFileName()
Gets the file name of the attachment.- Returns:
- The file name of the attachment.
-
getSize
int getSize()
Gets the size of the attachment in bytes.- Returns:
- The size of the attachment in bytes.
-
getUrl
URL getUrl()
Gets the url of the attachment.- Returns:
- The url of the attachment.
-
getProxyUrl
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
Optional<Integer> getHeight()
Gets the height of the attachment, if it's an image.- Returns:
- The height of the attachment.
-
getWidth
Optional<Integer> getWidth()
Gets the width of the attachment, if it's an image.- Returns:
- The width of the attachment.
-
downloadAsByteArray
CompletableFuture<byte[]> downloadAsByteArray()
Gets the attachment as byte array.- Returns:
- The attachment as byte array.
-
downloadAsImage
CompletableFuture<BufferedImage> downloadAsImage()
Downloads the attachment as image.- Returns:
- The attachment as image. Only present, if the attachment is an image.
- Throws:
IllegalStateException- If the attachment is not an image.
-
-