Class ConfigurableReply
- Direct Known Subclasses:
SendableReply
Builder for sending messages based on a GenericInteractionCreateEvent that supports adding components to
messages and changing the InteractionDefinition.ReplyConfig.
Example:
@Interaction
public class ExampleCommand {
@SlashCommand(value= "example command")
public void onCommand(CommandEvent event){
event.with().components(buttons("onButton")).reply("Hello World");
}
@Button("Press me!")
public void onButton(ComponentEvent event){
event.reply("You pressed me!");
}
}
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConfigurableReply(ConfigurableReply configurableReply) Constructs a new ConfigurableReply.ConfigurableReply(ReplyAction replyAction) Constructs a new ConfigurableReply. -
Method Summary
Modifier and TypeMethodDescriptionbuilder(Consumer<MessageCreateBuilder> builder) Access the underlyingMessageCreateBuilderfor configuration steps not covered byConfigurableReply.components(Component<?, ?, ?, ?>... components) components(String... components) Adds anActionRowto the reply and adds the passed components to it.editReply(boolean editReply) Whether to keep the original components when editing a message.Acknowledgement of this event with one or moreEmbeds.Acknowledgement of this event with one or moreEmbeds.Acknowledgement of this event with anEmbed.Acknowledgement of this event with anEmbed.ephemeral(boolean ephemeral) Whether to send ephemeral replies.keepComponents(boolean keepComponents) Whether to edit the original message or to send a new one.keepSelections(boolean keepSelections) Whether to keep the selections of a string select menu when sending edits.Acknowledgement of this event with a text message.
-
Field Details
-
replyAction
-
-
Constructor Details
-
ConfigurableReply
Constructs a new ConfigurableReply.- Parameters:
replyAction- the underlyingReplyAction
-
ConfigurableReply
Constructs a new ConfigurableReply.- Parameters:
configurableReply- theConfigurableReplyto copy
-
-
Method Details
-
ephemeral
Whether to send ephemeral replies. Default value is
false.Ephemeral messages have some limitations and will be removed once the user restarts their client. Limitations:
- Cannot contain any files/ attachments
- Cannot be reacted to
- Cannot be retrieved
This will override both
JDACBuilder.globalReplyConfig(InteractionDefinition.ReplyConfig)and anyReplyConfigannotation!- Parameters:
ephemeral-trueif to send ephemeral replies- Returns:
- the current instance for fluent interface
-
editReply
Whether to keep the original components when editing a message. Default value is
true.More formally, if editing a message and
keepComponentsistrue, the original message will first be queried and its components get added to the reply before it is sent.This will override both
JDACBuilder.globalReplyConfig(InteractionDefinition.ReplyConfig)and anyReplyConfigannotation!- Parameters:
editReply-trueif to keep the original components- Returns:
- the current instance for fluent interface
-
keepComponents
Whether to edit the original message or to send a new one. Default value is
true.The original message is always the very first reply that was sent. E.g. for a slash command event, which was replied to with a text message and a button, the original message is that very reply.
Subsequent replies to the same slash command event or the button event cannot be edited.
This will override both
JDACBuilder.globalReplyConfig(InteractionDefinition.ReplyConfig)and anyReplyConfigannotation!- Parameters:
keepComponents-trueif to edit the original method- Returns:
- the current instance for fluent interface
-
keepSelections
Whether to keep the selections of a string select menu when sending edits. This setting only has an effect withkeepComponents(boolean)true. -
builder
Access the underlying
MessageCreateBuilderfor configuration steps not covered byConfigurableReply.This method exposes the internal
MessageCreateBuilderused by JDA-Commands. Modifying fields that are also manipulated by the Reply API, like content or embeds, may lead to unexpected behaviour.Example:
event.with().builder(builder -> builder.setFiles(myFile)).reply("Hello World!"); -
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, seeI18n.localize(Locale, String, Entry...)- Returns:
- the
Messagethat got created - Implementation Requirements:
Internally this method must call
RestAction.complete(), thus theMessageobject can get returned directly.This might throw
RuntimeExceptions if JDA fails to send the message.
-
embeds
Acknowledgement of this event with one or more
Embeds.Resolves the
Embeds based on the given names. SeeEmbedConfigfor more information.- Parameters:
embeds- the name of theEmbeds to send- Returns:
- a new
SendableReply
-
embeds
Acknowledgement of this event with one or more
Embeds.See
EmbedConfigfor more information.- Parameters:
embeds- theEmbeds to send- Returns:
- a new
SendableReply
-
embeds
Acknowledgement of this event with an
Embed.Resolves the
Embedbased on the given name. SeeEmbedConfigfor more information.- Parameters:
embed- the name of theEmbedto sendconsumer- aConsumerallowing direct modification of theEmbedbefore sending it.- Returns:
- a new
SendableReply
-
embeds
Acknowledgement of this event with an
Embed.Resolves the
Embedbased on the given name. SeeEmbedConfigfor more information.- Parameters:
embed- the name of theEmbedto sendentry- the placeholders to use. SeeEmbed.placeholders(Entry...)entries- the placeholders to use. SeeEmbed.placeholders(Entry...)- Returns:
- a new
SendableReply
-
components
Adds an
ActionRowto the reply and adds the passed components to it.The components will always be enabled and runtime-bound. Use
components(Component...)if you want to modify these settings.The components must be defined in the same class where this method gets called!
Example:
@Interaction public class ExampleCommand { @SlashCommand(value= "example command") public void onCommand(CommandEvent event){ event.with().components("onButton").reply("Hello World"); } @Button("Press me!") public void onButton(ComponentEvent event){ event.reply("You pressed me!"); } }- Parameters:
components- the name of the components to add- Returns:
- the current instance for fluent interface
-
components
Adds an
ActionRowto the reply and adds the passedComponentto it.Example:
@Interaction public class ExampleCommand { @SlashCommand(value= "example command") public void onCommand(CommandEvent event){ event.with().components(Components.disabled("onButton")).reply("Hello World"); } @Button("Press me!") public void onButton(ComponentEvent event){ event.reply("You pressed me!"); } }- Parameters:
components- theComponentto add- Returns:
- the current instance for fluent interface
- See Also:
-