Reply Building¶
Note
All event types share the same Reply API. JDA-Commands will only acknowledge the interaction event just before sending the reply. If you need more time, e.g. for doing a database query, you can always manually acknowledge events by calling event#deferReply().
Text Messages¶
The simplest way of sending a reply is using the ReplyableEvent#reply(String, Entry...)
method. This will send a non-ephemeral text message. If the event has already been replied to, this method will edit the
original message instead of sending a new one by default.
The reply() method also has some useful overloads, you can find a full list here.
Embeds¶
JDA-Commands provides a rich Embed API to make working with Embeds easier. See the Embed Section of this wiki for
setup instructions. Once you have your EmbedDataSource
configured you can start using Embeds in your replies.
Use the ConfigurableReply object, which is accessed by calling
ReplyableEvent#with(),
to attach Embeds to your reply. The easiest way of replying with an Embed is to simply pass the Embeds name:
You can also pass multiple names or call the #embed(...) method multiple times:
Example
For modifying you can either use the Embed object or use a callback:
Example
Placeholders can be passed not only to the Embed
object, but also directly to the #embed(...) method:
Components¶
You can also reply with components. Here is a list of useful resources for working with components:
- Defining Buttons and Select Menus
- Replying with the Legacy Component System (ActionRows)
- Components V2 Guide
- Component Utils
Localization and Emojis¶
To avoid hardcoded values, all string properties of a component/the content of a message can be replaced by a localization key as supported by the current used Localization System.
Furthermore, it's possible to directly use placeholders. For more information on how to use placeholders please visit this page.
Also take a look at the general message resolution documentation.
Example
JDA-Commands has built in support for Unicode and application emoji aliases. If you want to use them, just take a look here.
Reply Configuration¶
You can change the default reply behavior by calling ReplyableEvent#with()
before sending the reply. This will return a ConfigurableReply
object to you, you can use to modify settings:
When calling ComponentEvent#with() you get a EditableConfigurableReply which allows for even more settings:
editReply(boolean): This will send a new message instead of editing the original one.keepComponents(boolean): This will keep the original componentskeepSelections(boolean): This will keep the user selections of the original components
@ReplyConfig Annotation¶
The @ReplyConfig
annotation provides a way to modify the default behavior of your replies. You can either annotate single methods or
entire interaction controllers. For a list of all possible configurations see the InteractionDefinition.ReplyConfig.Builder.
ReplyConfig Annotation
Global Reply Config¶
Alternatively, you can set a global reply config at the builder:
Global ReplyConfig
JDA-Commands will apply clashing ReplyConfigs in the following hierarchy:
with()#...callsReplyConfigmethod annotationReplyConfigclass annotation- global
ReplyConfig