Package discord4j.core.object.entity
Class Attachment
- java.lang.Object
-
- discord4j.core.object.entity.Attachment
-
- All Implemented Interfaces:
DiscordObject,Entity
public final class Attachment extends Object implements Entity
A Discord attachment.- See Also:
- Attachment Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringSPOILER_PREFIXThe prefix of the name of files which are displayed as spoilers.
-
Constructor Summary
Constructors Constructor Description Attachment(GatewayDiscordClient gateway, discord4j.discordjson.json.AttachmentData data)Constructs anAttachmentwith an associatedGatewayDiscordClientand Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)GatewayDiscordClientgetClient()Returns theGatewayDiscordClientthat created this object.Optional<String>getContentType()Gets the attachment's media type, if present.discord4j.discordjson.json.AttachmentDatagetData()Gets the data of the attachment.StringgetFilename()Gets the name of the file attached.OptionalIntgetHeight()Gets the height of the file, if present.SnowflakegetId()Gets the Snowflake that uniquely identifies this entity.StringgetProxyUrl()Gets a proxied URL of the file.intgetSize()Gets the size of the file in bytes.StringgetUrl()Gets the source URL of the file.OptionalIntgetWidth()Gets the width of the file, if present.inthashCode()booleanisSpoiler()Gets whether the attachment is a spoiler.StringtoString()
-
-
-
Field Detail
-
SPOILER_PREFIX
public static final String SPOILER_PREFIX
The prefix of the name of files which are displayed as spoilers.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Attachment
public Attachment(GatewayDiscordClient gateway, discord4j.discordjson.json.AttachmentData data)
Constructs anAttachmentwith an associatedGatewayDiscordClientand Discord data.- Parameters:
gateway- TheGatewayDiscordClientassociated to this object, must be non-null.data- The raw data as represented by Discord, must be non-null.
-
-
Method Detail
-
getClient
public GatewayDiscordClient getClient()
Description copied from interface:DiscordObjectReturns theGatewayDiscordClientthat created this object. Methods in it are exclusively based on the entity cache orStorein use. Refer to callinggetClient().rest()to access aDiscordClientthat is capable of requesting entities directly from the REST API.- Specified by:
getClientin interfaceDiscordObject- Returns:
- The
GatewayDiscordClientassociated to this object.
-
getId
public Snowflake getId()
Description copied from interface:EntityGets the Snowflake that uniquely identifies this entity.
-
getData
public discord4j.discordjson.json.AttachmentData getData()
Gets the data of the attachment.- Returns:
- The data of the attachment.
-
getFilename
public String getFilename()
Gets the name of the file attached.- Returns:
- The name of the file attached.
-
getSize
public int getSize()
Gets the size of the file in bytes.- Returns:
- The size of the file in bytes.
-
getUrl
public String getUrl()
Gets the source URL of the file.- Returns:
- The source URL of the file.
-
getProxyUrl
public String getProxyUrl()
Gets a proxied URL of the file.- Returns:
- A proxied URL of the file.
-
getHeight
public OptionalInt getHeight()
Gets the height of the file, if present.- Returns:
- The height of the file, if present.
-
getWidth
public OptionalInt getWidth()
Gets the width of the file, if present.- Returns:
- The width of the file, if present.
-
isSpoiler
public boolean isSpoiler()
Gets whether the attachment is a spoiler.- Returns:
trueif the attachment is a spoiler,falseotherwise.
-
getContentType
public Optional<String> getContentType()
Gets the attachment's media type, if present.- Returns:
- The attachment's media type, if present.
-
-