Class InteractionHookImpl
java.lang.Object
net.dv8tion.jda.internal.entities.AbstractWebhookClient<Message>
net.dv8tion.jda.internal.interactions.InteractionHookImpl
- All Implemented Interfaces:
ISnowflake
,WebhookClient<Message>
,InteractionHook
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInteractionHookImpl
(JDA api, String token) InteractionHookImpl
(DeferrableInteractionImpl interaction, JDA api) -
Method Summary
Modifier and TypeMethodDescriptionboolean
ack()
buildMessage
(DataObject json) deleteMessageById
(String messageId) Delete a message from this webhook.editRequest
(String messageId) void
Thecallback response
created by interaction replies likeIReplyCallback.reply(String)
or interaction updates likeIMessageEditCallback.editMessage(String)
.long
The unix millisecond timestamp for the expiration of this interaction hook.The interaction attached to this hook.boolean
Whether this InteractionHook contains acallback response
.boolean
isAck()
void
ready()
retrieveMessageById
(String messageId) Retrieves the message with the provided id.setCallbackResponse
(InteractionCallbackResponseImpl callbackResponse) setEphemeral
(boolean ephemeral) Whether messages sent from this interaction hook should be ephemeral by default.Methods inherited from class net.dv8tion.jda.internal.entities.AbstractWebhookClient
editMessageAttachmentsById, editMessageById, editMessageById, editMessageComponentsById, editMessageEmbedsById, getIdLong, getJDA, getToken, sendFiles, sendMessage, sendMessage, sendMessageComponents, sendMessageEmbeds, sendMessagePoll
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.interactions.InteractionHook
deleteOriginal, editOriginal, editOriginal, editOriginalAttachments, editOriginalAttachments, editOriginalComponents, editOriginalComponents, editOriginalComponents, editOriginalEmbeds, editOriginalEmbeds, editOriginalFormat, getJDA, isExpired, retrieveOriginal
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
Methods inherited from interface net.dv8tion.jda.api.entities.WebhookClient
deleteMessageById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageFormatById, editMessageFormatById, getToken, sendFiles, sendFiles, sendMessage, sendMessage, sendMessageComponents, sendMessageComponents, sendMessageComponents, sendMessageEmbeds, sendMessageEmbeds, sendMessageFormat, sendMessagePoll
-
Field Details
-
TIMEOUT_MESSAGE
- See Also:
-
-
Constructor Details
-
InteractionHookImpl
-
InteractionHookImpl
-
-
Method Details
-
ack
public boolean ack() -
isAck
public boolean isAck() -
ready
public void ready() -
fail
-
setCallbackResponse
-
getInteraction
Description copied from interface:InteractionHook
The interaction attached to this hook.- Specified by:
getInteraction
in interfaceInteractionHook
- Returns:
- The
Interaction
-
getCallbackResponse
Description copied from interface:InteractionHook
Thecallback response
created by interaction replies likeIReplyCallback.reply(String)
or interaction updates likeIMessageEditCallback.editMessage(String)
.Example
event.reply("foobar").queue(hook -> { var messageId = hook.getCallbackResponse().getMessage().getIdLong(); System.out.println(messageId); });
- Specified by:
getCallbackResponse
in interfaceInteractionHook
- Returns:
InteractionCallbackResponse
- See Also:
-
hasCallbackResponse
public boolean hasCallbackResponse()Description copied from interface:InteractionHook
Whether this InteractionHook contains acallback response
.
This will befalse
if the interaction has not yet been acknowledged.- Specified by:
hasCallbackResponse
in interfaceInteractionHook
- Returns:
- True, if this InteractionHook contains a callback response
- See Also:
-
getExpirationTimestamp
public long getExpirationTimestamp()Description copied from interface:InteractionHook
The unix millisecond timestamp for the expiration of this interaction hook.
An interaction hook expires after 15 minutes of its creation.- Specified by:
getExpirationTimestamp
in interfaceInteractionHook
- Returns:
- The timestamp in millisecond precision
- See Also:
-
setEphemeral
Description copied from interface:InteractionHook
Whether messages sent from this interaction hook should be ephemeral by default.
This does not affect message updates, including deferred replies sent withsendMessage(...)
methods.
When a message is ephemeral, it will only be visible to the user that used the interaction.Ephemeral messages have some limitations and will be removed once the user restarts their client.
Limitations:- Cannot be reacted to
- Can only be retrieved using the
InteractionHook
- In guilds the bot is not a member of,
if the member is unable to
use external application
, this usually happens for user-installed commands - If the interaction user is unable to
send messages
- If the content contains elements the user does not have the permission to send (like files or embeds)
- If the content triggered AutoMod
- Specified by:
setEphemeral
in interfaceInteractionHook
- Parameters:
ephemeral
- True if messages should be ephemeral- Returns:
- The same interaction hook instance
-
sendRequest
- Specified by:
sendRequest
in classAbstractWebhookClient<Message>
-
editRequest
- Specified by:
editRequest
in classAbstractWebhookClient<Message>
-
deleteMessageById
Description copied from interface:WebhookClient
Delete a message from this webhook.Use
setThreadId(threadId)
to delete messages from threads.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Specified by:
deleteMessageById
in interfaceWebhookClient<Message>
- Overrides:
deleteMessageById
in classAbstractWebhookClient<Message>
- Parameters:
messageId
- The id for the message to delete- Returns:
WebhookMessageDeleteAction
-
retrieveMessageById
Description copied from interface:WebhookClient
Retrieves the message with the provided id.
This only works for messages sent by this webhook. All other messages are unknown.Use
setThreadId(threadId)
to retrieve messages from threads.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
If the message is inaccessible to this webhook or does not exist.
- Specified by:
retrieveMessageById
in interfaceWebhookClient<Message>
- Returns:
WebhookMessageRetrieveAction
-
buildMessage
-