Interface IReplyCallback
- All Superinterfaces:
IDeferrableCallback
,Interaction
,ISnowflake
- All Known Subinterfaces:
ButtonInteraction
,CommandInteraction
,ComponentInteraction
,ContextInteraction<T>
,EntitySelectInteraction
,MessageContextInteraction
,ModalInteraction
,SelectMenuInteraction<T,
,S> SlashCommandInteraction
,StringSelectInteraction
,UserContextInteraction
- All Known Implementing Classes:
ButtonInteractionEvent
,EntitySelectInteractionEvent
,GenericCommandInteractionEvent
,GenericComponentInteractionCreateEvent
,GenericContextInteractionEvent
,GenericSelectMenuInteractionEvent
,MessageContextInteractionEvent
,ModalInteractionEvent
,SlashCommandInteractionEvent
,StringSelectInteractionEvent
,UserContextInteractionEvent
These replies automatically acknowledge the interaction and support deferring.
Deferred Replies
If an interaction reply is deferred using deferReply()
or deferReply(boolean)
,
the interaction hook
can be used to send a delayed/deferred reply with WebhookClient.sendMessage(String)
.
When using deferReply()
the first message sent to the InteractionHook
will be identical to using InteractionHook.editOriginal(String)
.
You must decide whether your reply will be ephemeral or not before calling deferReply()
. So design your code flow with that in mind!
If a reply 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 reply.
-
Method Summary
Modifier and TypeMethodDescriptionAcknowledge this interaction and defer the reply to a later time.default ReplyCallbackAction
deferReply
(boolean ephemeral) Acknowledge this interaction and defer the reply to a later time.default ReplyCallbackAction
Reply to this interaction and acknowledge it.default ReplyCallbackAction
reply
(MessageCreateData message) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyComponents
(Collection<? extends LayoutComponent> components) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyComponents
(LayoutComponent component, LayoutComponent... other) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyEmbeds
(Collection<? extends MessageEmbed> embeds) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyEmbeds
(MessageEmbed embed, MessageEmbed... embeds) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyFiles
(Collection<? extends FileUpload> files) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyFiles
(FileUpload... files) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyFormat
(String format, Object... args) Reply to this interaction and acknowledge it.default ReplyCallbackAction
replyPoll
(MessagePollData poll) Reply to this interaction and acknowledge it.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
-
deferReply
Acknowledge this interaction and defer the reply to a later time.
This will send a<Bot> is thinking...
message in chat that will be updated later through eitherInteractionHook.editOriginal(String)
orWebhookClient.sendMessage(String)
.You can use
deferReply(true)
to send a deferred ephemeral reply. If your initial deferred message is not ephemeral it cannot be made ephemeral later. Your first message to theInteractionHook
will inherit whether the message is ephemeral or not from this deferred reply.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.Use
reply(String)
to reply directly.- Returns:
ReplyCallbackAction
-
deferReply
Acknowledge this interaction and defer the reply to a later time.
This will send a<Bot> is thinking...
message in chat that will be updated later through eitherInteractionHook.editOriginal(String)
orWebhookClient.sendMessage(String)
.You can use
deferReply()
ordeferReply(false)
to send a non-ephemeral deferred reply. If your initial deferred message is ephemeral it cannot be made non-ephemeral later. Your first message to theInteractionHook
will inherit whether the message is ephemeral or not from this deferred reply.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.Use
reply(String)
to reply directly.Ephemeral messages have some limitations and will be removed once the user restarts their client.
When a message is ephemeral, it will only be visible to the user that used the interaction.
Limitations:- Cannot contain any files/attachments
- Cannot be reacted to
- Cannot be retrieved
- Parameters:
ephemeral
- True, if this message should only be visible to the interaction user- Returns:
ReplyCallbackAction
-
reply
Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filter
- Parameters:
message
- TheMessageCreateData
to send- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided- See Also:
-
replyPoll
Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filterPOLL_INVALID_CHANNEL_TYPE
This channel does not allow pollsPOLL_WITH_UNUSABLE_EMOJI
This poll uses an external emoji that the bot is not allowed to use
- Parameters:
poll
- TheMessagePollData
to send- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided- See Also:
-
reply
Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filter
- Parameters:
content
- The message content to send- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided or the content is longer thanMessage.MAX_CONTENT_LENGTH
characters
-
replyEmbeds
@Nonnull @CheckReturnValue default ReplyCallbackAction replyEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds) Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filter
- Parameters:
embeds
- TheMessageEmbeds
to send- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided
-
replyEmbeds
@Nonnull @CheckReturnValue default ReplyCallbackAction replyEmbeds(@Nonnull MessageEmbed embed, @Nonnull MessageEmbed... embeds) Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filter
- Parameters:
embed
- The message embed to sendembeds
- Any additional embeds to send- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided
-
replyComponents
@Nonnull @CheckReturnValue default ReplyCallbackAction replyComponents(@Nonnull Collection<? extends LayoutComponent> components) Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filter
- Parameters:
components
- TheLayoutComponents
to send, such asActionRow
- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided or more than 5 component layouts are provided
-
replyComponents
@Nonnull @CheckReturnValue default ReplyCallbackAction replyComponents(@Nonnull LayoutComponent component, @Nonnull LayoutComponent... other) Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filter
- Parameters:
component
- TheLayoutComponent
to sendother
- Any additionLayoutComponents
to send- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided or more than 5 component layouts are provided
-
replyFormat
@Nonnull @CheckReturnValue default ReplyCallbackAction replyFormat(@Nonnull String format, @Nonnull Object... args) Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.Possible
ErrorResponses
include:UNKNOWN_INTERACTION
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filter
- Parameters:
format
- Format string for the message contentargs
- Format arguments for the content- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If the format string is null or the resulting content is longer thanMessage.MAX_CONTENT_LENGTH
characters
-
replyFiles
@Nonnull @CheckReturnValue default ReplyCallbackAction replyFiles(@Nonnull Collection<? extends FileUpload> files) Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.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
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filterREQUEST_ENTITY_TOO_LARGE
If the total sum of uploaded bytes exceeds the guild'supload limit
- Parameters:
files
- TheFileUploads
to attach to the message- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided- See Also:
-
replyFiles
Reply to this interaction and acknowledge it.
This will send a reply message for this interaction. You can usesetEphemeral(true)
to only let the target user see the message. Replies are non-ephemeral by default.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION
.If your handling can take longer than 3 seconds, due to various rate limits or other conditions, you should use
deferReply()
instead.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
If the interaction has already been acknowledged or timed outMESSAGE_BLOCKED_BY_AUTOMOD
If this message was blocked by anAutoModRule
MESSAGE_BLOCKED_BY_HARMFUL_LINK_FILTER
If this message was blocked by the harmful link filterREQUEST_ENTITY_TOO_LARGE
If the total sum of uploaded bytes exceeds the guild'supload limit
- Parameters:
files
- TheFileUploads
to attach to the message- Returns:
ReplyCallbackAction
- Throws:
IllegalArgumentException
- If null is provided- See Also:
-