Interface ComponentInteraction
-
- All Superinterfaces:
Interaction
,ISnowflake
- All Known Subinterfaces:
ButtonInteraction
,SelectionMenuInteraction
- All Known Implementing Classes:
ButtonClickEvent
,GenericComponentInteractionCreateEvent
,SelectionMenuEvent
public interface ComponentInteraction extends Interaction
Interaction on a messageComponent
.Instead of
Interaction.deferReply()
andInteraction.reply(String)
you can usedeferEdit()
andeditMessage(String)
with these interactions! You can only acknowledge an interaction once!
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description UpdateInteractionAction
deferEdit()
No-op acknowledgement of this interaction.default UpdateInteractionAction
editComponents(java.util.Collection<? extends ComponentLayout> components)
Acknowledgement of this interaction with a message update.default UpdateInteractionAction
editComponents(ComponentLayout... components)
Acknowledgement of this interaction with a message update.default UpdateInteractionAction
editMessage(java.lang.String content)
Acknowledgement of this interaction with a message update.default UpdateInteractionAction
editMessage(Message message)
Acknowledgement of this interaction with a message update.default UpdateInteractionAction
editMessageEmbeds(java.util.Collection<? extends MessageEmbed> embeds)
Acknowledgement of this interaction with a message update.default UpdateInteractionAction
editMessageEmbeds(MessageEmbed... embeds)
Acknowledgement of this interaction with a message update.default UpdateInteractionAction
editMessageFormat(java.lang.String format, java.lang.Object... args)
Acknowledgement of this interaction with a message update.MessageChannel
getChannel()
The respectiveMessageChannel
for this interaction.Component
getComponent()
TheComponent
instance.java.lang.String
getComponentId()
The custom component Id provided to the component when it was originally created.Component.Type
getComponentType()
TheComponent.Type
Message
getMessage()
TheMessage
instance.default java.lang.String
getMessageId()
The id of the message.long
getMessageIdLong()
The id of the message.-
Methods inherited from interface net.dv8tion.jda.api.interactions.Interaction
deferReply, deferReply, getChannelType, getGuild, getGuildChannel, getHook, getJDA, getMember, getMessageChannel, getPrivateChannel, getTextChannel, getToken, getType, getTypeRaw, getUser, getVoiceChannel, isAcknowledged, isFromGuild, reply, reply, replyEmbeds, replyEmbeds, replyFormat
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
getComponentId
@Nonnull java.lang.String getComponentId()
The custom component Id provided to the component when it was originally created.
This value should be used to determine what action to take in regards to this interaction.
This id does not have to be numerical.- Returns:
- The component ID
-
getComponent
@Nullable Component getComponent()
TheComponent
instance.
This is null on interactions for ephemeral messages.- Returns:
- The
Component
, or null if this message is ephemeral
-
getMessageIdLong
long getMessageIdLong()
The id of the message.- Returns:
- The message id
-
getMessageId
@Nonnull default java.lang.String getMessageId()
The id of the message.- Returns:
- The message id
-
getComponentType
@Nonnull Component.Type getComponentType()
TheComponent.Type
- Returns:
- The
Component.Type
-
getChannel
@Nonnull MessageChannel getChannel()
The respectiveMessageChannel
for this interaction.- Specified by:
getChannel
in interfaceInteraction
- Returns:
- The
MessageChannel
-
deferEdit
@Nonnull @CheckReturnValue UpdateInteractionAction 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:
UpdateInteractionAction
that can be used to update the message- See Also:
editMessage(String)
-
editMessage
@Nonnull @CheckReturnValue default UpdateInteractionAction editMessage(@Nonnull Message message)
Acknowledgement of this interaction with a message update.
You can useInteraction.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
Interaction.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:
UpdateInteractionAction
that can be used to further update the message- Throws:
java.lang.IllegalArgumentException
- If the provided message is null
-
editMessage
@Nonnull @CheckReturnValue default UpdateInteractionAction editMessage(@Nonnull java.lang.String content)
Acknowledgement of this interaction with a message update.
You can useInteraction.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
Interaction.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:
UpdateInteractionAction
that can be used to further update the message- Throws:
java.lang.IllegalArgumentException
- If the provided content is null
-
editComponents
@Nonnull @CheckReturnValue default UpdateInteractionAction editComponents(@Nonnull java.util.Collection<? extends ComponentLayout> components)
Acknowledgement of this interaction with a message update.
You can useInteraction.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
Interaction.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:
UpdateInteractionAction
that can be used to further update the message- Throws:
java.lang.IllegalArgumentException
- If the provided components are null
-
editComponents
@Nonnull @CheckReturnValue default UpdateInteractionAction editComponents(@Nonnull ComponentLayout... components)
Acknowledgement of this interaction with a message update.
You can useInteraction.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
Interaction.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:
UpdateInteractionAction
that can be used to further update the message- Throws:
java.lang.IllegalArgumentException
- If the provided components are null
-
editMessageEmbeds
@Nonnull @CheckReturnValue default UpdateInteractionAction editMessageEmbeds(@Nonnull java.util.Collection<? extends MessageEmbed> embeds)
Acknowledgement of this interaction with a message update.
You can useInteraction.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
Interaction.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:
UpdateInteractionAction
that can be used to further update the message- Throws:
java.lang.IllegalArgumentException
- If any of the provided embeds is null
-
editMessageEmbeds
@Nonnull @CheckReturnValue default UpdateInteractionAction editMessageEmbeds(@Nonnull MessageEmbed... embeds)
Acknowledgement of this interaction with a message update.
You can useInteraction.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
Interaction.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:
UpdateInteractionAction
that can be used to further update the message- Throws:
java.lang.IllegalArgumentException
- If any of the provided embeds is null
-
editMessageFormat
@Nonnull @CheckReturnValue default UpdateInteractionAction editMessageFormat(@Nonnull java.lang.String format, @Nonnull java.lang.Object... args)
Acknowledgement of this interaction with a message update.
You can useInteraction.getHook()
to edit the message further.You can only use deferEdit() or editMessage() once per interaction! Use
Interaction.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:
UpdateInteractionAction
that can be used to further update the message- Throws:
java.lang.IllegalArgumentException
- If the provided format is null
-
-