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 AttachedFile
MAX_DESCRIPTION_LENGTH -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPart(okhttp3.MultipartBody.Builder builder, int index) Used internally to build the multipart request.voidclose()booleanvoidForces 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.The updated attachment description.longThe Snowflake id of this entity.getName()The existing attachment filename.Whether this attachment will be marked as a spoiler after the update request.inthashCode()toAttachmentData(int index) Used internally to build attachment descriptions for requests.toString()withDescription(String description) The new description for this attachment.withSpoiler(boolean spoiler) Whether this attachment will be marked as a spoiler after the update request.Methods inherited from interface 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
-
getSpoiler
Whether this attachment will be marked as a spoiler after the update request.This is
nullfor attachment updates that do not overwrite the spoiler state.- Returns:
true, if the attachment will be marked as a spoiler,falseotherwise, ornullif not provided
-
getDescription
The updated attachment description.- Returns:
- The description, or
nullif not provided
-
withDescription
@Nonnull @Contract("_->new") @CheckReturnValue public AttachmentUpdate withDescription(@Nonnull String description) The new description for this attachment.- Parameters:
description- The updated description- Returns:
- The updated AttachmentUpdate
- Throws:
IllegalArgumentException- Ifnullis provided, or the description is longer than 1024
-
withSpoiler
Whether this attachment will be marked as a spoiler after the update request.- Parameters:
spoiler- True, if the attachment will be marked as a spoiler, false otherwise- Returns:
- The updated AttachmentUpdate
-
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
public void addPart(@Nonnull okhttp3.MultipartBody.Builder builder, int index) 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
-
equals
-
hashCode
-
toString
-