Interface MessageEditCallbackAction
- All Superinterfaces:
InteractionCallbackAction<InteractionHook>
,RestAction<InteractionHook>
InteractionCallbackAction
which can be used to edit the message for an interaction.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.requests.restaction.interactions.InteractionCallbackAction
InteractionCallbackAction.ResponseType
-
Method Summary
Modifier and TypeMethodDescriptiondefault MessageEditCallbackAction
addFile
(byte[] data, String name, AttachmentOption... options) Adds the providedbyte[]
as file data.default MessageEditCallbackAction
addFile
(File file, String name, AttachmentOption... options) Adds the providedFile
.default MessageEditCallbackAction
addFile
(File file, AttachmentOption... options) Adds the providedFile
.addFile
(InputStream data, String name, AttachmentOption... options) Adds the providedInputStream
as file data.Closes all owned resources used for this request.deadline
(long timestamp) Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.default MessageEditCallbackAction
retainFiles
(Collection<? extends Message.Attachment> attachments) Removes all attachments that are currently attached to the existing message except for the ones provided.default MessageEditCallbackAction
retainFiles
(Message.Attachment... attachments) Removes all attachments that are currently attached to the existing message except for the ones provided.default MessageEditCallbackAction
retainFilesById
(long... ids) Removes all attachments that are currently attached to the existing message except for the ones provided.default MessageEditCallbackAction
retainFilesById
(String... ids) Removes all attachments that are currently attached to the existing message except for the ones provided.retainFilesById
(Collection<String> ids) Removes all attachments that are currently attached to the existing message except for the ones provided.default MessageEditCallbackAction
setActionRow
(Collection<? extends ItemComponent> components) Set only one action row for convenience.default MessageEditCallbackAction
setActionRow
(ItemComponent... components) Set only one action row for convenience.default MessageEditCallbackAction
setActionRows
(Collection<? extends ActionRow> rows) Set the action rows for the message.setActionRows
(ActionRow... rows) Set the action rows for the message.setCheck
(BooleanSupplier checks) Sets the last-second checks before finally executing the http request in the queue.setContent
(String content) Set the new content for this message.setEmbeds
(Collection<? extends MessageEmbed> embeds) Set theMessageEmbeds
for the messagedefault MessageEditCallbackAction
setEmbeds
(MessageEmbed... embeds) Set theMessageEmbeds
for the messageTimeout for this RestAction instance.Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
Method Details
-
setCheck
Description copied from interface:RestAction
Sets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalse
or throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.- Specified by:
setCheck
in interfaceRestAction<InteractionHook>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
-
timeout
Description copied from interface:RestAction
Timeout for this RestAction instance.
If the request doesn't get executed within the timeout it will fail.When a RestAction times out, it will fail with a
TimeoutException
. This is the same asdeadline(System.currentTimeMillis() + unit.toMillis(timeout))
.Example
action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
- Specified by:
timeout
in interfaceRestAction<InteractionHook>
- Parameters:
timeout
- The timeout to useunit
-Unit
for the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
-
deadline
Description copied from interface:RestAction
Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.
If the deadline is reached, the request will fail with aTimeoutException
.This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.
Example
action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
- Specified by:
deadline
in interfaceRestAction<InteractionHook>
- Parameters:
timestamp
- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
-
closeResources
Description copied from interface:InteractionCallbackAction
Closes all owned resources used for this request.This closes all files added, if applicable.
- Specified by:
closeResources
in interfaceInteractionCallbackAction<InteractionHook>
- Returns:
- This instance for chaining.
-
setContent
Set the new content for this message.- Parameters:
content
- The new message content- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If the provided content is longer thanMAX_CONTENT_LENGTH
characters
-
setEmbeds
@Nonnull @CheckReturnValue default MessageEditCallbackAction setEmbeds(@Nonnull MessageEmbed... embeds) Set theMessageEmbeds
for the message- Parameters:
embeds
- The message embeds- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If null is provided, or one of the embeds is too big, or more than 10 embeds are provided
-
setEmbeds
@Nonnull @CheckReturnValue MessageEditCallbackAction setEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds) Set theMessageEmbeds
for the message- Parameters:
embeds
- The message embeds- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If null is provided, one of the embeds is too big, or more than 10 embeds are provided
-
setActionRows
@Nonnull @CheckReturnValue default MessageEditCallbackAction setActionRows(@Nonnull Collection<? extends ActionRow> rows) Set the action rows for the message.- Parameters:
rows
- The new action rows- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
-- If null is provided, or more than 5 ActionRows are provided
- If any custom
id
is duplicated - If any of the provided ActionRows are not compatible with messages
- See Also:
-
setActionRows
Set the action rows for the message.- Parameters:
rows
- The new action rows- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
-- If null is provided, or more than 5 ActionRows are provided
- If any custom
id
is duplicated - If any of the provided ActionRows are not compatible with messages
- See Also:
-
setActionRow
@Nonnull @CheckReturnValue default MessageEditCallbackAction setActionRow(@Nonnull ItemComponent... components) Set only one action row for convenience.- Parameters:
components
- The action row components, such asButtons
- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
-- If null is provided, or more than 5 ItemComponents are provided
- If any custom
id
is duplicated - If any of the provided ItemComponents are not compatible with messages
- See Also:
-
setActionRow
@Nonnull @CheckReturnValue default MessageEditCallbackAction setActionRow(@Nonnull Collection<? extends ItemComponent> components) Set only one action row for convenience.- Parameters:
components
- The action row components, such asButtons
- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
-- If null is provided, or more than 5 ItemComponents are provided
- If any custom
id
is duplicated - If any of the provided ItemComponents are not compatible with messages
- See Also:
-
addFile
@Nonnull @CheckReturnValue default MessageEditCallbackAction addFile(@Nonnull File file, @Nonnull AttachmentOption... options) Adds the providedFile
.
The stream will be closed upon execution!
The provided file will be appended to the message.- Parameters:
file
- TheFile
data to upload in response to the interaction.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If the provided file isnull
.
-
addFile
@Nonnull @CheckReturnValue default MessageEditCallbackAction addFile(@Nonnull File file, @Nonnull String name, @Nonnull AttachmentOption... options) Adds the providedFile
.
The stream will be closed upon execution!
The provided file will be appended to the message.The
name
parameter is used to inform Discord about what the file should be called. This is 2 fold:- The file name provided is the name that is found in
Message.Attachment.getFileName()
after upload and it is the name that will show up in the client when the upload is displayed.
Note: The fileName does not show up on the Desktop client for images. It does on mobile however. - The extension of the provided fileName also determines how Discord will treat the file. Discord currently only has special handling for image file types, but the fileName's extension must indicate that it is an image file. This means it has to end in something like .png, .jpg, .jpeg, .gif, etc. As a note, you can also not provide a full name for the file and instead ONLY provide the extension like "png" or "gif" and Discord will generate a name for the upload and append the fileName as the extension.
- Parameters:
file
- TheFile
data to upload in response to the interaction.name
- The file name that should be sent to discordoptions
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If the provided file or filename isnull
.
- The file name provided is the name that is found in
-
addFile
@Nonnull @CheckReturnValue default MessageEditCallbackAction addFile(@Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options) Adds the providedbyte[]
as file data.
The stream will be closed upon execution!
The provided file will be appended to the message.- Parameters:
data
- Thebyte[]
data to upload in response to the interaction.name
- The file name that should be sent to discord
Refer to the documentation foraddFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If the provided data or filename isnull
.
-
addFile
@Nonnull @CheckReturnValue MessageEditCallbackAction addFile(@Nonnull InputStream data, @Nonnull String name, @Nonnull AttachmentOption... options) Adds the providedInputStream
as file data.
The stream will be closed upon execution!
The provided file will be appended to the message.- Parameters:
data
- The InputStream data to upload in response to the interaction.name
- The file name that should be sent to discord
Refer to the documentation foraddFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If the provided data or filename isnull
.
-
retainFilesById
@Nonnull @CheckReturnValue MessageEditCallbackAction retainFilesById(@Nonnull Collection<String> ids) Removes all attachments that are currently attached to the existing message except for the ones provided.
For exampleretainFilesById(Arrays.asList("123"))
would remove all attachments except for the one with the id 123.To remove all attachments from the message you can pass an empty list.
- Parameters:
ids
- The ids for the attachments which should be retained on the message- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If any of the ids is null or not a valid snowflake
-
retainFilesById
@Nonnull @CheckReturnValue default MessageEditCallbackAction retainFilesById(@Nonnull String... ids) Removes all attachments that are currently attached to the existing message except for the ones provided.
For exampleretainFilesById(Arrays.asList("123"))
would remove all attachments except for the one with the id 123.To remove all attachments from the message you can pass an empty list.
- Parameters:
ids
- The ids for the attachments which should be retained on the message- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If any of the ids is null or not a valid snowflake
-
retainFilesById
Removes all attachments that are currently attached to the existing message except for the ones provided.
For exampleretainFilesById(Arrays.asList("123"))
would remove all attachments except for the one with the id 123.To remove all attachments from the message you can pass an empty list.
- Parameters:
ids
- The ids for the attachments which should be retained on the message- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If any of the ids is null or not a valid snowflake
-
retainFiles
@Nonnull @CheckReturnValue default MessageEditCallbackAction retainFiles(@Nonnull Collection<? extends Message.Attachment> attachments) Removes all attachments that are currently attached to the existing message except for the ones provided.
For exampleretainFiles(message.getAttachments().subList(1, message.getAttachments().size()))
would only remove the first attachment from the message.To remove all attachments from the message you can pass an empty list.
- Parameters:
attachments
- The attachments which should be retained on the message- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If any of the ids is null or not a valid snowflake
-
retainFiles
@Nonnull @CheckReturnValue default MessageEditCallbackAction retainFiles(@Nonnull Message.Attachment... attachments) Removes all attachments that are currently attached to the existing message except for the ones provided.
For exampleretainFiles(message.getAttachments().subList(1, message.getAttachments().size()))
would only remove the first attachment from the message.To remove all attachments from the message you can pass an empty list.
- Parameters:
attachments
- The attachments which should be retained on the message- Returns:
- The same update action, for chaining convenience
- Throws:
IllegalArgumentException
- If any of the ids is null or not a valid snowflake
-