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 String
SPOILER_PREFIX
The 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 anAttachment
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
GatewayDiscordClient
getClient()
Returns theGatewayDiscordClient
that created this object.Optional<String>
getContentType()
Gets the attachment's media type, if present.discord4j.discordjson.json.AttachmentData
getData()
Gets the data of the attachment.String
getFilename()
Gets the name of the file attached.OptionalInt
getHeight()
Gets the height of the file, if present.Snowflake
getId()
Gets the Snowflake that uniquely identifies this entity.String
getProxyUrl()
Gets a proxied URL of the file.int
getSize()
Gets the size of the file in bytes.String
getUrl()
Gets the source URL of the file.OptionalInt
getWidth()
Gets the width of the file, if present.int
hashCode()
boolean
isSpoiler()
Gets whether the attachment is a spoiler.String
toString()
-
-
-
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 anAttachment
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- TheGatewayDiscordClient
associated 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:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- Returns:
- The
GatewayDiscordClient
associated to this object.
-
getId
public Snowflake getId()
Description copied from interface:Entity
Gets 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:
true
if the attachment is a spoiler,false
otherwise.
-
getContentType
public Optional<String> getContentType()
Gets the attachment's media type, if present.- Returns:
- The attachment's media type, if present.
-
-