Class ReplyableEvent<T extends GenericInteractionCreateEvent>

java.lang.Object
io.github.kaktushose.jdac.dispatching.events.Event<T>
io.github.kaktushose.jdac.dispatching.events.ReplyableEvent<T>
All Implemented Interfaces:
Reply, ISnowflake, Interaction
Direct Known Subclasses:
ModalEvent, ModalReplyableEvent

public abstract sealed class ReplyableEvent<T extends GenericInteractionCreateEvent> extends Event<T> implements Reply permits ModalEvent, ModalReplyableEvent<T>

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 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 respective InteractionDefinition.ReplyConfig to set the ephemeral flag. If your initial deferred message is ephemeral it cannot be made non-ephemeral later. Use deferReply(boolean) to override the InteractionDefinition.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. Use deferReply() to use the InteractionDefinition.ReplyConfig for 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

      public Button getButton(String button)

      Gets a Button based on the method name and transforms it into a JDA Button.

      The button will be linked to the current Runtime. This may be useful if you want to send a component without using the framework.

      Parameters:
      button - the name of the button defining method
      Returns:
      the JDA Button
    • getButton

      public Button getButton(Class<?> origin, String button)

      Gets a Button based on the method name and the given class and transforms it into a JDA Button.

      The button will be runtime-independent. This may be useful if you want to send a component without using the framework.

      Parameters:
      origin - the Class of the method
      button - the name of the button defining method
      Returns:
      the JDA Button
    • getSelectMenu

      public SelectMenu getSelectMenu(String menu)

      Gets a StringSelectMenu or EntitySelectMenu based on the method name and transforms it into a JDA SelectMenu.

      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

      public SelectMenu getSelectMenu(Class<?> origin, String menu)

      Gets a StringSelectMenu or EntitySelectMenu based on the method name and transforms it into a JDA SelectMenu.

      The select menu will be runtime-independent. This may be useful if you want to send a component without using the framework.

      Parameters:
      origin - the Class of the method
      menu - the name of the select menu
      Returns:
      the JDA SelectMenu
    • embed

      public Embed embed(String name)

      Gets an Embed based on the given name.

      Use findEmbed(String) if you cannot ensure that the Embed exists.

      Parameters:
      name - the name of the Embed
      Returns:
      the Embed
      Throws:
      IllegalArgumentException - if no Embed with the given name exists in the configured data sources
    • findEmbed

      public Optional<Embed> findEmbed(String name)

      Gets an Embed based on the given name and wraps it in an Optional.

      Use this instead of embed(String) if you cannot ensure that the Embed exists.

      Parameters:
      name - the name of the Embed
      Returns:
      an Optional holding the Embed or an empty Optional if an Embed with the given name doesn't exist
    • with

      public ConfigurableReply with()

      Entry point for configuring a reply.

      Returns a new ConfigurableReply that can be used to append components or override reply settings.

      Returns:
      a new ConfigurableReply
      See Also:
    • reply

      public Message reply(String message, Entry... placeholder)
      Acknowledgement of this event with a text message.
      Specified by:
      reply in interface Reply
      Parameters:
      message - the message to send or the localization key
      placeholder - the placeholders to use to perform localization, see [I18n#localize(Locale , String, Entry...) ]
      Returns:
      the Message that got created
    • reply

      public Message reply(MessageEmbed first, MessageEmbed... additional)
      Acknowledgement of this event with a MessageEmbed.
      Specified by:
      reply in interface Reply
      Parameters:
      first - the MessageEmbed to send
      additional - additional MessageEmbeds to send
      Returns:
      the Message that got created
    • reply

      public Message reply(MessageCreateData data)
      Acknowledgement of this event with a MessageCreateData.
      Specified by:
      reply in interface Reply
      Parameters:
      data - the MessageCreateData to send
      Returns:
      the Message that got created