Interface ReplyManager
- All Known Implementing Classes:
InteractionReplyManager,MessageReplyManager
Note that if a reply specification has the ReplySpec.privately() field as
absent, the default for the manager will be used. Furthermore, if the initial reply
was deferred, the value of that field on the first reply is ignored
and the default is used instead (further replies are unaffected).
Note also that not all managers are valid forever; for example, interaction-based
managers expire after 15 minutes (once the interaction token expires). If handling
takes a long time and requires sending further replies, use detach() to
obtain an independent, long-term manager after sending the initial responses.
- Since:
- 1.0
- Version:
- 1.0
- Implementation Requirements:
- Implementations are required to be concurrency-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError message used when trying to access the initial reply before sending one. -
Method Summary
Modifier and TypeMethodDescriptiondefault ReplyMonoadd()Sends a new reply.Sends a new reply.default ReplyMonoadd(EmbedCreateSpec... embeds) Sends a new reply.Sends a new reply.Sends a new reply.add(MessageCreateSpec spec) Sends a new reply.default ReplyMonoSends a new reply.defer()Defers the initial response, signaling it to the user in some form.detach()Obtains a detached copy of this manager, where the existing reply chain is the same, but new replies are sent independently.default Replyget()Retrieves the initial reply.get(@org.checkerframework.checker.index.qual.NonNegative int index) Retrieves a reply.
-
Field Details
-
NO_RESPONSE_ERROR
Error message used when trying to access the initial reply before sending one.- See Also:
-
-
Method Details
-
defer
Defers the initial response, signaling it to the user in some form. Whether it will be done privately or not is determined by the manager's default.If a deferral was already made or a reply was already sent, this method (and by extension the returned Mono) has no effect.
- Returns:
- A Mono that completes once deferral is complete.
-
add
Sends a new reply.- Parameters:
spec- The reply specification.- Returns:
- The created reply.
-
add
Sends a new reply.- Returns:
- A reply builder Mono that can be configured with the target reply then subscribed to send the reply.
-
add
Sends a new reply.- Parameters:
spec- The message specification.- Returns:
- The created reply.
- See Also:
-
ReplyUtils.from(MessageCreateSpec)add(CommandReplySpec)
-
add
Sends a new reply.- Parameters:
spec- The message specification.- Returns:
- The created reply.
- See Also:
-
ReplyUtils.from(InteractionApplicationCommandCallbackSpec)add(CommandReplySpec)
-
add
Sends a new reply.- Parameters:
spec- The message specification.- Returns:
- The created reply.
- See Also:
-
ReplyUtils.from(InteractionFollowupCreateSpec)add(CommandReplySpec)
-
add
Sends a new reply.- Parameters:
content- The message content.- Returns:
- A reply builder Mono initialized with the given content.
-
add
Sends a new reply.- Parameters:
embeds- The message embeds.- Returns:
- A reply builder Mono initialized with the given embeds.
-
get
Reply get(@org.checkerframework.checker.index.qual.NonNegative int index) throws IndexOutOfBoundsException Retrieves a reply.- Parameters:
index- The reply index.- Returns:
- The reply.
- Throws:
IndexOutOfBoundsException- if there is no reply with that index.
-
get
Retrieves the initial reply.- Returns:
- The reply.
- Throws:
IllegalStateException- if an initial reply was not sent yet.
-
detach
Obtains a detached copy of this manager, where the existing reply chain is the same, but new replies are sent independently.An initial reply must have already been sent before detaching (i.e.
get()should not throw an exception); otherwise the returned mono will finish with an error.The new manager may, in some cases, not use the same method to send replies (for example, it might use regular messages while the original manager uses interaction responses). This causes the side effect that, while existing replies are still accessible via
get(int), some functionality may be unavailable (for example, ephemeral interaction responses).However, managers returned by this method are required to use a sending method that does not expire, and so may be used in cases where the original reply manager might expire before processing finishes.
Note that some events (like slash commands) require a response to be sent natively or else it is considered to have failed; a best-effort attempt is made to catch cases where detaching is attempted before a required response and throw an exception early for visibily, however not all cases can be caught as it might depend on actions outside of the manager's control (for example a component interaction might be responded to by editing the original message instead).
- Returns:
- A new detached manager. May result in an
IllegalStateExceptionif the manager detects that switching to a detached manager on the current state would cause an error or timeout later. - API Note:
- The detachment process occurs at subscription time, and the source manager must be valid at that time, so make sure to do so before a long processing period if needed.
-