Interface IMessageEditCallback
- All Superinterfaces:
IDeferrableCallback
,Interaction
,ISnowflake
- All Known Subinterfaces:
ButtonInteraction
,ComponentInteraction
,EntitySelectInteraction
,ModalInteraction
,SelectMenuInteraction<T,
,S> StringSelectInteraction
- All Known Implementing Classes:
ButtonInteractionEvent
,EntitySelectInteractionEvent
,GenericComponentInteractionCreateEvent
,GenericSelectMenuInteractionEvent
,ModalInteractionEvent
,StringSelectInteractionEvent
Editing a message using these methods will automatically acknowledge the interaction.
Deferred Edits
Similar to IReplyCallback
, message edits can be deferred and performed later with deferEdit()
.
A deferred edit tells Discord, that you intend to edit the message this interaction was performed on, but will do so later.
However, you can defer the edit and never do it, which is effectively a no-operation acknowledgement of the interaction.
If an edit is deferred
, it becomes the original message of the interaction hook.
This means all the methods with original
in the name, such as InteractionHook.editOriginal(String)
,
will affect that original message you edited.
-
Method Summary
Modifier and TypeMethodDescriptionNo-op acknowledgement of this interaction.default MessageEditCallbackAction
editComponents
(Collection<? extends MessageTopLevelComponent> components) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editComponents
(MessageTopLevelComponent... components) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editComponents
(ComponentTree<? extends MessageTopLevelComponent> tree) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editMessage
(String content) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editMessage
(MessageEditData message) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editMessageAttachments
(Collection<? extends AttachedFile> attachments) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editMessageAttachments
(AttachedFile... attachments) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editMessageEmbeds
(Collection<? extends MessageEmbed> embeds) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editMessageEmbeds
(MessageEmbed... embeds) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editMessageFormat
(String format, Object... args) Acknowledgement of this interaction with a message update.Methods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IDeferrableCallback
getHook
Methods inherited from interface net.dv8tion.jda.api.interactions.Interaction
getChannel, getChannelId, getChannelIdLong, getChannelType, getContext, getEntitlements, getGuild, getGuildChannel, getGuildLocale, getIntegrationOwners, getJDA, getMember, getMessageChannel, getToken, getType, getTypeRaw, getUser, getUserLocale, isAcknowledged, isFromAttachedGuild, isFromGuild
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
Method Details
-
deferEdit
No-op acknowledgement of this interaction.
This tells discord you intend to update the message that the triggering component is a part of using theInteractionHook
instead of sending a reply message. You are not required to actually update the message, this will simply acknowledge that you accepted the interaction.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.Use
editMessage(String)
to edit it directly.- Returns:
MessageEditCallbackAction
that can be used to update the message- See Also:
-
editMessage
@Nonnull @CheckReturnValue default MessageEditCallbackAction editMessage(@Nonnull MessageEditData message) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
message
- The new message content to use- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
- If the provided message is null
-
editMessage
Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
content
- The new message content to use- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
- If the provided content is null or longer than 2000 characters
-
editComponents
@Nonnull @CheckReturnValue default MessageEditCallbackAction editComponents(@Nonnull Collection<? extends MessageTopLevelComponent> components) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
components
- TheMessageTopLevelComponents
to set, can be empty to remove components, can contain up to 5 V1 components. There are no limits for V2 components outside the total tree size (40).- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
-- If
null
is provided - If any of the provided components are not compatible with messages
- If
- See Also:
-
editComponents
@Nonnull @CheckReturnValue default MessageEditCallbackAction editComponents(@Nonnull MessageTopLevelComponent... components) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
components
- TheMessageTopLevelComponents
to set, can be empty to remove components, can contain up to 5 V1 components. There are no limits for V2 components outside the total tree size (40).- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
-- If
null
is provided - If any of the provided components are not compatible with messages
- If
- See Also:
-
editComponents
@Nonnull @CheckReturnValue default MessageEditCallbackAction editComponents(@Nonnull ComponentTree<? extends MessageTopLevelComponent> tree) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
tree
- The newComponentTree
to set, can be empty to remove components, containing up to 5 V1 components. There are no limits for V2 components outside the total tree size (40).- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
-- If
null
is provided - If any of the provided components are not compatible with messages
- When using components V1, if more than 5 components are provided
- If
- See Also:
-
editMessageEmbeds
@Nonnull @CheckReturnValue default MessageEditCallbackAction editMessageEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
embeds
- The newMessageEmbeds
- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
- If null or more than 10 embeds are provided
-
editMessageEmbeds
@Nonnull @CheckReturnValue default MessageEditCallbackAction editMessageEmbeds(@Nonnull MessageEmbed... embeds) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
embeds
- The new message embeds to include in the message- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
- If null or more than 10 embeds are provided
-
editMessageFormat
@Nonnull @CheckReturnValue default MessageEditCallbackAction editMessageFormat(@Nonnull String format, @Nonnull Object... args) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
format
- The format string for the new message contentargs
- The format arguments- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
- If the provided format is null
-
editMessageAttachments
@Nonnull @CheckReturnValue default MessageEditCallbackAction editMessageAttachments(@Nonnull Collection<? extends AttachedFile> attachments) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Resource Handling Note: Once the request is handed off to the requester, for example when you call
RestAction.queue()
, the requester will automatically clean up all opened files by itself. You are only responsible to close them yourself if it is never handed off properly. For instance, if an exception occurs after usingFileUpload.fromData(File)
, before callingRestAction.queue()
. You can safely use a try-with-resources to handle this, sinceFileUpload.close()
becomes ineffective once the request is handed off.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
attachments
- The new attachments of the message (Can beFileUploads
orAttachmentUpdates
)- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
- If null is provided- See Also:
-
editMessageAttachments
@Nonnull @CheckReturnValue default MessageEditCallbackAction editMessageAttachments(@Nonnull AttachedFile... attachments) Acknowledgement of this interaction with a message update.
You can useIDeferrableCallback.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
IDeferrableCallback.getHook()
for any additional updates.You only have 3 seconds to acknowledge an interaction!
Resource Handling Note: Once the request is handed off to the requester, for example when you call
RestAction.queue()
, the requester will automatically clean up all opened files by itself. You are only responsible to close them yourself if it is never handed off properly. For instance, if an exception occurs after usingFileUpload.fromData(File)
, before callingRestAction.queue()
. You can safely use a try-with-resources to handle this, sinceFileUpload.close()
becomes ineffective once the request is handed off.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
When the acknowledgement is sent after the interaction expired.INVALID_FORM_BODY
Components V2 is used by the to-be-edited message, and this request has non-empty content or embeds.
- Parameters:
attachments
- The new attachments of the message (Can beFileUploads
orAttachmentUpdates
)- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
- If null is provided- See Also:
-