Interface ReplyManager

All Known Implementing Classes:
MessageReplyManager

public interface ReplyManager
Manages the replies sent by a command.

All methods capture the state of the manager at the time of calling; for example, add(MessageCreateSpec) will use the configuration that is in place at the time it is called, not at the time the returned Mono is subscribed; and methods like edit(MessageEditSpec) expect the referenced reply to have already been sent.

Since:
1.0
Version:
1.0
  • Field Details

    • NO_RESPONSE_ERROR

      static final String NO_RESPONSE_ERROR
      Error message used when trying to access the initial reply before sending one.
      See Also:
  • Method Details

    • setPrivate

      ReplyManager setPrivate(boolean priv)
      Sets whether new replies should be sent in DMs.

      Existing replies are not affected.

      Parameters:
      priv - If new replies should be sent in a private channel.
      Returns:
      This.
    • setEphemeral

      ReplyManager setEphemeral(ReplyManager.EphemeralType ephemeral)
      Sets whether new replies should be ephemeral.

      Existing replies are not affected.

      Parameters:
      ephemeral - The ephemeral type for new replies.
      Returns:
      This.
    • setDeleteDelay

      ReplyManager setDeleteDelay(Duration delay)
      Sets the delay before deleting new replies, if they are timed.

      Existing replies are not affected.

      Parameters:
      delay - The delay.
      Returns:
      This.
    • defer

      Mono<Void> defer()
      Defers initial response, indicating to the user that the response is being processed.
      Returns:
      A Mono that completes after deferral is processed.
    • reply

      Sends an initial reply.
      Parameters:
      spec - The message specification.
      Returns:
      A Mono that completes after the reply is sent.
      Throws:
      IllegalStateException - if an initial reply was already made.
    • reply

      default Mono<Void> reply(String content) throws IllegalStateException
      Sends an initial reply.
      Parameters:
      content - The message content.
      Returns:
      A Mono that completes after the reply is sent.
      Throws:
      IllegalStateException - if an initial reply was already made.
    • reply

      default Mono<Void> reply(EmbedCreateSpec... embeds) throws IllegalStateException
      Sends an initial reply.
      Parameters:
      embeds - The message embeds.
      Returns:
      A Mono that completes after the reply is sent.
      Throws:
      IllegalStateException - if an initial reply was already made.
    • add

      Adds a reply to the chain (either initial or followup).
      Parameters:
      spec - The message specification.
      Returns:
      The created message and its index.
    • add

      default Mono<Tuple2<Message,Integer>> add(String content)
      Adds a reply to the chain (either initial or followup).
      Parameters:
      content - The message content.
      Returns:
      The created message and its index.
    • add

      default Mono<Tuple2<Message,Integer>> add(EmbedCreateSpec... embeds)
      Adds a reply to the chain (either initial or followup).
      Parameters:
      embeds - The message embeds.
      Returns:
      The created message and its index.
    • edit

      default Mono<Message> edit(MessageEditSpec spec) throws IllegalStateException
      Edits the initial reply.
      Parameters:
      spec - The edit specification.
      Returns:
      The edited message. Fails with an IllegalStateException if the initial reply was deleted.
      Throws:
      IllegalStateException - if an initial reply was not sent yet.
    • edit

      default Mono<Message> edit(String content) throws IllegalStateException
      Edits the initial reply.
      Parameters:
      content - The message content.
      Returns:
      The edited message. Fails with an IllegalStateException if the initial reply was deleted.
      Throws:
      IllegalStateException - if an initial reply was not sent yet.
    • edit

      default Mono<Message> edit(EmbedCreateSpec... embeds) throws IllegalStateException
      Edits the initial reply.
      Parameters:
      embeds - The message embeds.
      Returns:
      The edited message. Fails with an IllegalStateException if the initial reply was deleted.
      Throws:
      IllegalStateException - if an initial reply was not sent yet.
    • edit

      Mono<Message> edit(int index, MessageEditSpec spec) throws IndexOutOfBoundsException
      Edits a reply.
      Parameters:
      index - The reply index.
      spec - The edit specification.
      Returns:
      The edited message. Fails with an IllegalStateException if the initial reply was deleted.
      Throws:
      IndexOutOfBoundsException - if there is no reply with that index.
    • edit

      default Mono<Message> edit(int index, String content) throws IndexOutOfBoundsException
      Edits a reply.
      Parameters:
      index - The reply index.
      content - The message content.
      Returns:
      The edited message. Fails with an IllegalStateException if the initial reply was deleted.
      Throws:
      IndexOutOfBoundsException - if there is no reply with that index.
    • edit

      default Mono<Message> edit(int index, EmbedCreateSpec... embeds) throws IndexOutOfBoundsException
      Edits a reply.
      Parameters:
      index - The reply index.
      embeds - The message embeds.
      Returns:
      The edited message. Fails with an IllegalStateException if the initial reply was deleted.
      Throws:
      IndexOutOfBoundsException - if there is no reply with that index.
    • get

      Mono<Message> get(int index) throws IndexOutOfBoundsException
      Retrieves a reply.
      Parameters:
      index - The reply index.
      Returns:
      The reply. Fails with an IllegalStateException if the reply was deleted.
      Throws:
      IndexOutOfBoundsException - if there is no reply with that index.
    • get

      default Mono<Message> get() throws IllegalStateException
      Retrieves the initial reply.
      Returns:
      The reply. Fails with an IllegalStateException if the initial reply was deleted.
      Throws:
      IllegalStateException - if an initial reply was not sent yet.
    • delete

      Mono<Void> delete(int index) throws IndexOutOfBoundsException
      Deletes a reply.

      Note that this does not change the index of other replies within this manager.

      Parameters:
      index - The reply index.
      Returns:
      A Mono that completes when the reply is deleted. Fails with an IllegalStateException if the reply was already deleted.
      Throws:
      IndexOutOfBoundsException - if there is no reply with that index.
    • delete

      default Mono<Void> delete() throws IllegalStateException
      Deletes the initial reply.

      Note that this does not change the index of other replies within this manager.

      Returns:
      A Mono that completes when the reply is deleted. Fails with an IllegalStateException if the initial reply was already deleted.
      Throws:
      IllegalStateException - if an initial reply was not sent yet.
    • longTerm

      ReplyManager longTerm()
      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 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.