Class MessageReply

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

public sealed class MessageReply extends Object implements Reply permits ConfigurableReply

Simple builder for sending text messages based on a GenericInteractionCreateEvent.

More formally, can be used to send an arbitrary amount of message replies to the text channel the GenericInteractionCreateEvent was executed in.

Example:

new MessageReply(event, definition, new ReplyConfig()).reply(errorMessage);
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final net.dv8tion.jda.api.utils.messages.MessageCreateBuilder
     
    protected final InteractionDefinition
     
    protected boolean
     
    protected boolean
     
    protected final net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
     
    protected boolean
     
    protected static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MessageReply(@NotNull MessageReply reply)
    Constructs a new MessageReply.
    MessageReply(@NotNull net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent event, @NotNull InteractionDefinition definition, InteractionDefinition.ReplyConfig replyConfig)
    Constructs a new MessageReply.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected @NotNull net.dv8tion.jda.api.entities.Message
    Sends the reply to Discord and blocks the current thread until the message was sent.
    net.dv8tion.jda.api.entities.Message
    reply(@NotNull String message)
    Acknowledgement of this event with a text message.
    net.dv8tion.jda.api.entities.Message
    reply(@NotNull net.dv8tion.jda.api.EmbedBuilder builder)
    Acknowledgement of this event with a text message.
    net.dv8tion.jda.api.entities.Message
    reply(@NotNull net.dv8tion.jda.api.utils.messages.MessageCreateData message)
    Acknowledgement of this event with a text message.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.github.kaktushose.jda.commands.dispatching.reply.Reply

    reply, reply
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • event

      protected final net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent event
    • definition

      protected final InteractionDefinition definition
    • builder

      protected final net.dv8tion.jda.api.utils.messages.MessageCreateBuilder builder
    • ephemeral

      protected boolean ephemeral
    • editReply

      protected boolean editReply
    • keepComponents

      protected boolean keepComponents
  • Constructor Details

  • Method Details

    • reply

      public net.dv8tion.jda.api.entities.Message reply(@NotNull @NotNull String message)
      Description copied from interface: Reply
      Acknowledgement of this event with a text message.
      Specified by:
      reply in interface Reply
      Parameters:
      message - the message to send
      Returns:
      the Message that got created
    • reply

      public net.dv8tion.jda.api.entities.Message reply(@NotNull @NotNull net.dv8tion.jda.api.utils.messages.MessageCreateData message)
      Description copied from interface: Reply
      Acknowledgement of this event with a text message.
      Specified by:
      reply in interface Reply
      Parameters:
      message - the MessageCreateData to send
      Returns:
      the Message that got created
    • reply

      public net.dv8tion.jda.api.entities.Message reply(@NotNull @NotNull net.dv8tion.jda.api.EmbedBuilder builder)
      Description copied from interface: Reply
      Acknowledgement of this event with a text message.
      Specified by:
      reply in interface Reply
      Parameters:
      builder - the EmbedBuilder to send
      Returns:
      the Message that got created
    • complete

      @NotNull protected @NotNull net.dv8tion.jda.api.entities.Message complete()
      Sends the reply to Discord and blocks the current thread until the message was sent.
      Returns:
      the Message that got created
      Implementation Note:

      This method can handle both message replies and message edits. it will check if the interaction got acknowledged and will acknowledge it if necessary before sending or editing a message. After that, WebhookClient.sendMessage(MessageCreateData) or respectively InteractionHook.editOriginal(MessageEditData) will be called.

      If editing a message and keepComponents is true, queries the original message first and adds its components to the reply before sending it.