Class MessageReplyManager

java.lang.Object
dev.sympho.modular_commands.impl.context.MessageReplyManager
All Implemented Interfaces:
ReplyManager

public class MessageReplyManager extends Object
Reply manager for message-based commands.
Since:
1.0
Version:
1.0
  • Field Details

    • replies

      protected final List<Reply> replies
      The sent replies.
    • sendLock

      protected final dev.sympho.reactor_utils.concurrent.ReactiveLock sendLock
      The lock for send ordering.
    • defaultPrivate

      protected final boolean defaultPrivate
      Whether replies are private by default.
    • deferred

      protected final boolean deferred
      Whether the first reply is deferred.
  • Constructor Details

    • MessageReplyManager

      @SideEffectFree public MessageReplyManager(Message original, Mono<MessageChannel> publicChannel, @Nullable Mono<PrivateChannel> privateChannel, boolean defaultPrivate, boolean deferred)
      Creates a new manager.
      Parameters:
      original - The message that triggered the command.
      publicChannel - The public channel to send messages in.
      privateChannel - The private channel to send messages in. May be null if the command is called from a private channel.
      defaultPrivate - Whether replies are private by default.
      deferred - Whether the first reply is deferred.
  • Method Details

    • send

      protected Mono<Reply> send(int index, CommandReplySpec spec)
      Sends a new reply.
      Parameters:
      index - The index of the created reply.
      spec - The reply specification.
      Returns:
      The created reply.
    • longTerm

      public ReplyManager longTerm()
      Description copied from interface: ReplyManager
      Obtains a manager that is a continuation of this one and has the same configuration, but is guaranteed to continue working long-term by using alternate sending methods if necessary (for example, it might use regular messages instead of interaction replies).

      Note that, while the existing replies are still accessible (by using ReplyManager.get(int)), editing them may not be possible (for example, an interaction-ephemeral response).

      There is no guarantee that the returned manager is independent from this one; using this manager after calling this method causes undefined behavior.

      Returns:
      The long-term manager.
    • add

      public Mono<Reply> add(CommandReplySpec spec)
      Description copied from interface: ReplyManager
      Sends a new reply.
      Specified by:
      add in interface ReplyManager
      Parameters:
      spec - The reply specification.
      Returns:
      The created reply.
    • get

      public Reply get(int index) throws IndexOutOfBoundsException
      Description copied from interface: ReplyManager
      Retrieves a reply.
      Specified by:
      get in interface ReplyManager
      Parameters:
      index - The reply index.
      Returns:
      The reply.
      Throws:
      IndexOutOfBoundsException - if there is no reply with that index.