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 TypeMethodDescriptionvoid
addPart
(okhttp3.MultipartBody.Builder builder, int index) Used internally to build the multipart request.void
close()
void
Forces the underlying resource to be closed, even if the file is already handled by a request.static AttachmentUpdate
fromAttachment
(long id) Creates anAttachmentUpdate
with the given attachment id.static AttachmentUpdate
fromAttachment
(String id) Creates anAttachmentUpdate
with the given attachment id.static AttachmentUpdate
fromAttachment
(Message.Attachment attachment) Creates anAttachmentUpdate
with the given attachment.long
The 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, wait
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
Method Details
-
fromAttachment
Creates anAttachmentUpdate
with 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 anAttachmentUpdate
with 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 anAttachmentUpdate
with 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
null
if not provided
-
getIdLong
public long getIdLong()Description copied from interface:ISnowflake
The Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLong
in interfaceISnowflake
- Returns:
- Long containing the Id.
-
addPart
Description copied from interface:AttachedFile
Used 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:
addPart
in interfaceAttachedFile
- Parameters:
builder
- TheMultipartBody.Builder
used for the request bodyindex
- The index of the attachment, ignored forAttachmentUpdate
-
toAttachmentData
Description copied from interface:AttachedFile
Used internally to build attachment descriptions for requests.
This contains the id/index of the attachment, and the name of the file.- Specified by:
toAttachmentData
in interfaceAttachedFile
- Parameters:
index
- The reference index (should be same asAttachedFile.addPart(MultipartBody.Builder, int)
)- Returns:
DataObject
for the attachment
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
forceClose
public void forceClose()Description copied from interface:AttachedFile
Forces the underlying resource to be closed, even if the file is already handled by a request.- Specified by:
forceClose
in interfaceAttachedFile
-
toString
-