Class ReplyableEvent<T extends GenericInteractionCreateEvent>
- All Implemented Interfaces:
ISnowflake, Interaction
- Direct Known Subclasses:
ModalEvent, ModalReplyableEvent
Subtype of Event that supports replying to the GenericInteractionCreateEvent with text messages.
You can either reply directly by using one of the reply methods, like reply(String, Entry...), or you can call
with() to use a ConfigurableReply to append components or override reply settings from the
ReplyConfig.
Example:
public void onInteraction(ReplayableEvent<?> event) {
event.reply("Hello World");
}
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAcknowledge this interaction and defer the reply to a later time.abstract voiddeferReply(boolean ephemeral) Acknowledge this interaction and defer the reply to a later time.Gets anEmbedbased on the given name.getSelectMenu(Class<?> origin, String menu) getSelectMenu(String menu) Acknowledgement of this event with a text message.reply(Collection<MessageTopLevelComponent> components, Entry... placeholder) Acknowledgement of this event with V2 Components.reply(MessageTopLevelComponent component, Entry... placeholder) Acknowledgement of this event with V2 Components.reply(MessageEmbed first, MessageEmbed... additional) Acknowledgement of this event with aMessageEmbed.reply(MessageCreateData message) Acknowledgement of this event with aMessageCreateData.with()Entry point for configuring a reply.Methods inherited from class Event
closeRuntime, getChannel, getChannelIdLong, getContext, getEntitlements, getGuild, getIdLong, getIntegrationOwners, getJDA, getMember, getToken, getTypeRaw, getUser, getUserLocale, interactionInstance, introspection, isAcknowledged, jdaEvent, kv, messageResolver, resolve, resolve, runtimeIdMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Interaction
getChannelId, getChannelType, getGuildChannel, getGuildLocale, getMessageChannel, getType, isFromAttachedGuild, isFromGuildMethods inherited from interface ISnowflake
getId, getTimeCreated
-
Constructor Details
-
ReplyableEvent
public ReplyableEvent()
-
-
Method Details
-
deferReply
public void 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. This will use the respectiveInteractionDefinition.ReplyConfigto set the ephemeral flag. If your initial deferred message is ephemeral it cannot be made non-ephemeral later. UsedeferReply(boolean)to override theInteractionDefinition.ReplyConfig.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receive
ErrorResponse.UNKNOWN_INTERACTION.Use
reply(String, Entry...)to reply directly. -
deferReply
public abstract void deferReply(boolean ephemeral) 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. This will use the passed boolean to set the ephemeral flag. If your initial deferred message is ephemeral it cannot be made non-ephemeral later. UsedeferReply()to use theInteractionDefinition.ReplyConfigfor the ephemeral flag.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receive
ErrorResponse.UNKNOWN_INTERACTION.Use
reply(String, Entry...)to reply directly.- Parameters:
ephemeral- yes
-
getButton
-
getButton
-
getSelectMenu
Gets a
StringMenuorEntityMenubased on the method name and transforms it into a JDASelectMenu.The select menu will be linked to the current
Runtime. This may be useful if you want to send a component without using the framework.- Parameters:
menu- the name of the select menu- Returns:
- the JDA
SelectMenu
-
getSelectMenu
Gets a
StringMenuorEntityMenubased on the method name and transforms it into a JDASelectMenu.The select menu will be
runtime-independent. This may be useful if you want to send a component without using the framework.- Parameters:
origin- theClassof the methodmenu- the name of the select menu- Returns:
- the JDA
SelectMenu
-
embed
Gets an
Embedbased on the given name.Use
findEmbed(String)if you cannot ensure that theEmbedexists.- Parameters:
name- the name of theEmbed- Returns:
- the
Embed - Throws:
IllegalArgumentException- if noEmbedwith the given name exists in the configured data sources
-
findEmbed
Gets an
Embedbased on the given name and wraps it in anOptional.Use this instead of
embed(String)if you cannot ensure that theEmbedexists. -
with
Entry point for configuring a reply.
Returns a new
ConfigurableReplythat can be used to append components or override reply settings.- Returns:
- a new
ConfigurableReply - See Also:
-
reply
Acknowledgement of this event with V2 Components.
Using V2 components removes the top-level component limit, and allows more components in total (40).
They also allow you to use a larger choice of components, such as any component extending
MessageTopLevelComponent, as long as they are compatible.The character limit for the messages also gets changed to 4000.
This, however, comes with a few drawbacks:
- You cannot send content, embeds, polls or stickers
- It does not support voice messages
- It does not support previewing files
- URLs don't create embeds
- You cannot switch this message back to not using Components V2 (you can however upgrade a message to V2)
- Parameters:
component- theMessageTopLevelComponentto reply withplaceholder- the placeholders to use. SeePlaceholderResolver
-
reply
Acknowledgement of this event with V2 Components.
Using V2 components removes the top-level component limit, and allows more components in total (40).
They also allow you to use a larger choice of components, such as any component extending
MessageTopLevelComponent, as long as they are compatible.The character limit for the messages also gets changed to 4000.
This, however, comes with a few drawbacks:
- You cannot send content, embeds, polls or stickers
- It does not support voice messages
- It does not support previewing files
- URLs don't create embeds
- You cannot switch this message back to not using Components V2 (you can however upgrade a message to V2)
- Parameters:
components- aCollectionofMessageTopLevelComponents to reply withplaceholder- the placeholders to use. SeePlaceholderResolver
-
reply
Acknowledgement of this event with a text message.- Parameters:
message- the message to send or the localization keyplaceholder- the placeholders to use to perform localization, see [I18n#localize(Locale , String, Entry...) ]- Returns:
- the
Messagethat got created - Implementation Requirements:
Internally this method calls
RestAction.complete(), thus theMessageobject can get returned directly.This might throw
RuntimeExceptions if JDA fails to send the message.
-
reply
Acknowledgement of this event with aMessageEmbed.- Parameters:
first- theMessageEmbedto sendadditional- additionalMessageEmbeds to send- Returns:
- the
Messagethat got created - Implementation Requirements:
Internally this method calls
RestAction.complete(), thus theMessageobject can get returned directly.This might throw
RuntimeExceptions if JDA fails to send the message.
-
reply
Acknowledgement of this event with aMessageCreateData.- Parameters:
message- theMessageCreateDatato send- Returns:
- the
Messagethat got created - Implementation Requirements:
Internally this method calls
RestAction.complete(), thus theMessageobject can get returned directly.This might throw
RuntimeExceptions if JDA fails to send the message.
-