Class ConfigurableReply

java.lang.Object
com.github.kaktushose.jda.commands.dispatching.reply.MessageReply
com.github.kaktushose.jda.commands.dispatching.reply.ConfigurableReply
All Implemented Interfaces:
Reply
Direct Known Subclasses:
ComponentReply

public sealed class ConfigurableReply extends MessageReply permits ComponentReply

Subtype of MessageReply that supports adding components to messages and changing the 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 Details

  • Constructor Details

    • ConfigurableReply

      public ConfigurableReply(@NotNull @NotNull MessageReply reply, @NotNull @NotNull InteractionRegistry registry, @NotNull @NotNull String runtimeId)
      Constructs a new ConfigurableReply.
      Parameters:
      reply - the underlying MessageReply
      registry - the corresponding InteractionRegistry
      runtimeId - the corresponding Runtime
    • ConfigurableReply

      public ConfigurableReply(@NotNull @NotNull ConfigurableReply reply)
      Constructs a new ConfigurableReply.
      Parameters:
      reply - the ConfigurableReply to copy
  • Method Details

    • ephemeral

      @NotNull public @NotNull ConfigurableReply ephemeral(boolean 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

      invalid reference
      GlobalReplyConfig
      and any ReplyConfig annotation!**
      Parameters:
      ephemeral - true if to send ephemeral replies
      Returns:
      the current instance for fluent interface
    • editReply

      @NotNull public @NotNull ConfigurableReply editReply(boolean editReply)

      Whether to keep the original components when editing a message. Default value is true.

      More formally, if editing a message and keepComponents is true, the original message will first be queried and its components get added to the reply before it is sent.

      **This will override both

      invalid reference
      GlobalReplyConfig
      and any ReplyConfig annotation!**
      Parameters:
      editReply - true if to keep the original components
      Returns:
      the current instance for fluent interface
    • keepComponents

      @NotNull public @NotNull ConfigurableReply keepComponents(boolean 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

      invalid reference
      GlobalReplyConfig
      and any ReplyConfig annotation!**
      Parameters:
      keepComponents - true if to edit the original method
      Returns:
      the current instance for fluent interface
    • components

      @NotNull public @NotNull ComponentReply components(@NotNull @NotNull String... components)

      Adds an ActionRow to 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

      @NotNull public @NotNull ComponentReply components(@NotNull @NotNull Component... components)

      Adds an ActionRow to the reply and adds the passed Component to it.

      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(Components.disabled("onButton")).reply("Hello World");
          }
      
          @Button("Press me!")
          public void onButton(ComponentEvent event) {
              event.reply("You pressed me!");
          }
      }
      
      Parameters:
      components - the Component to add
      Returns:
      the current instance for fluent interface
      See Also: