Class ReplyableEvent<T extends GenericInteractionCreateEvent>
- All Implemented Interfaces:
Reply, 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) Gets aStringSelectMenuorEntitySelectMenubased on the method name and transforms it into a JDASelectMenu.getSelectMenu(String menu) Gets aStringSelectMenuorEntitySelectMenubased on the method name and transforms it into a JDASelectMenu.voidRemoves all components from the original message.Acknowledgement of this event with a text message.reply(MessageEmbed first, MessageEmbed... additional) Acknowledgement of this event with aMessageEmbed.reply(MessageCreateData data) 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, i18n, interactionInstance, isAcknowledged, jdaEvent, kv, localize, messageResolver, 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
-
removeComponents
public void removeComponents()Removes all components from the original message.
The original message is the message, from which this event (interaction) originates. For example if this event is a ButtonEvent, the original message will be the message to which the pressed button is attached to.
-
getButton
-
getButton
-
getSelectMenu
Gets a
StringSelectMenuorEntitySelectMenubased 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
StringSelectMenuorEntitySelectMenubased 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 a text message. -
reply
Acknowledgement of this event with aMessageEmbed.- Specified by:
replyin interfaceReply- Parameters:
first- theMessageEmbedto sendadditional- additionalMessageEmbeds to send- Returns:
- the
Messagethat got created
-
reply
Acknowledgement of this event with aMessageCreateData.- Specified by:
replyin interfaceReply- Parameters:
data- theMessageCreateDatato send- Returns:
- the
Messagethat got created
-