Package net.dv8tion.jda.api.utils
Class AttachmentUpdate
java.lang.Object
net.dv8tion.jda.api.utils.AttachmentUpdate
- All Implemented Interfaces:
Closeable,AutoCloseable,ISnowflake,AttachedFile
Represents existing message attachment.
This is primarily used for message edit requests, to specify which attachments to retain in the message after the update.
This is primarily used for message edit requests, to specify which attachments to retain in the message after the update.
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.utils.AttachedFile
MAX_DESCRIPTION_LENGTH -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPart(okhttp3.MultipartBody.Builder builder, int index) Used internally to build the multipart request.voidclose()voidForces the underlying resource to be closed, even if the file is already handled by a request.static AttachmentUpdatefromAttachment(long id) Creates anAttachmentUpdatewith the given attachment id.static AttachmentUpdatefromAttachment(String id) Creates anAttachmentUpdatewith the given attachment id.static AttachmentUpdatefromAttachment(Message.Attachment attachment) Creates anAttachmentUpdatewith the given attachment.longThe Snowflake id of this entity.getName()The existing attachment filename.toAttachmentData(int index) Used internally to build attachment descriptions for requests.toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
Method Details
-
fromAttachment
Creates anAttachmentUpdatewith the given attachment id.
This is primarily used for message edit requests, to specify which attachments to retain in the message after the update.- Parameters:
id- The id of the attachment to retain- Returns:
AttachmentUpdate
-
fromAttachment
Creates anAttachmentUpdatewith the given attachment id.
This is primarily used for message edit requests, to specify which attachments to retain in the message after the update.- Parameters:
id- The id of the attachment to retain- Returns:
AttachmentUpdate- Throws:
IllegalArgumentException- If the id is not a valid snowflake
-
fromAttachment
Creates anAttachmentUpdatewith the given attachment.
This is primarily used for message edit requests, to specify which attachments to retain in the message after the update.- Parameters:
attachment- The attachment to retain- Returns:
AttachmentUpdate
-
getName
The existing attachment filename.- Returns:
- The filename, or
nullif not provided
-
getIdLong
public long getIdLong()Description copied from interface:ISnowflakeThe Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLongin interfaceISnowflake- Returns:
- Long containing the Id.
-
addPart
Description copied from interface:AttachedFileUsed internally to build the multipart request.The index can be used as a unique identifier for the multipart name, which is required to be unique by Discord.
- Specified by:
addPartin interfaceAttachedFile- Parameters:
builder- TheMultipartBody.Builderused for the request bodyindex- The index of the attachment, ignored forAttachmentUpdate
-
toAttachmentData
Description copied from interface:AttachedFileUsed internally to build attachment descriptions for requests.
This contains the id/index of the attachment, and the name of the file.- Specified by:
toAttachmentDatain interfaceAttachedFile- Parameters:
index- The reference index (should be same asAttachedFile.addPart(MultipartBody.Builder, int))- Returns:
DataObjectfor the attachment
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
forceClose
public void forceClose()Description copied from interface:AttachedFileForces the underlying resource to be closed, even if the file is already handled by a request.- Specified by:
forceClosein interfaceAttachedFile
-
toString
-