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 LayoutComponent> components) Acknowledgement of this interaction with a message update.default MessageEditCallbackAction
editComponents
(LayoutComponent... components) 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, getEntitlements, getGuild, getGuildChannel, getGuildLocale, getJDA, getMember, getMessageChannel, getToken, getType, getTypeRaw, getUser, getUserLocale, isAcknowledged, 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.- 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.- 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 LayoutComponent> 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.- Parameters:
components
- The new message components, such asActionRow
- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
-- If any of the provided LayoutComponents is null
- If any of the provided Components are not compatible with messages
- If more than 5 component layouts are provided
- See Also:
-
editComponents
@Nonnull @CheckReturnValue default MessageEditCallbackAction editComponents(@Nonnull LayoutComponent... 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.- Parameters:
components
- The new message components, such asActionRow
- Returns:
MessageEditCallbackAction
that can be used to further update the message- Throws:
IllegalArgumentException
-- If any of the provided LayoutComponents are null
- If any of the provided Components are not compatible with messages
- If more than 5 component layouts are provided
- 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.- 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.- 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.- 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_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.- 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!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_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.- 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:
-