Class InteractionReplyManager
- All Implemented Interfaces:
ReplyManager
- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Whether the event has been acknowledged (first reply deferred or sent).protected final boolean
Whether replies are private by default.The sent replies.protected final dev.sympho.reactor_utils.concurrent.ReactiveLock
The lock for send ordering.Fields inherited from interface dev.sympho.bot_utils.event.reply.ReplyManager
NO_RESPONSE_ERROR
-
Constructor Summary
ConstructorDescriptionInteractionReplyManager
(String referenceTitle, Supplier<? extends Iterable<? extends EmbedCreateFields.Field>> referenceFields, DeferrableInteractionEvent event, boolean defaultPrivate, boolean requireReply) Creates a new message. -
Method Summary
Modifier and TypeMethodDescriptionSends 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.doDefer()
Applies deferral to the initial response.protected ReplyManager
doDetach()
Creates a new detached manager.get
(@org.checkerframework.checker.index.qual.NonNegative int index) Retrieves a reply.Sends a new reply.
-
Field Details
-
replies
The sent replies. -
sendLock
protected final dev.sympho.reactor_utils.concurrent.ReactiveLock sendLockThe lock for send ordering. -
defaultPrivate
protected final boolean defaultPrivateWhether replies are private by default. -
acked
protected boolean ackedWhether the event has been acknowledged (first reply deferred or sent).
-
-
Constructor Details
-
InteractionReplyManager
public InteractionReplyManager(String referenceTitle, Supplier<? extends Iterable<? extends EmbedCreateFields.Field>> referenceFields, DeferrableInteractionEvent event, boolean defaultPrivate, boolean requireReply) Creates a new message.- Parameters:
referenceTitle
- The title of the reference message.referenceFields
- Generator of the fields for the reference message.event
- The backing interaction event.defaultPrivate
- Whether replies are private by default.requireReply
- Whether to require that a reply is made before detaching.
-
-
Method Details
-
doDefer
Applies deferral to the initial response.- Returns:
- A Mono that completes once deferral is complete.
-
send
protected Mono<Reply> send(@org.checkerframework.checker.index.qual.NonNegative int index, ReplySpec spec) Sends a new reply.- Parameters:
index
- The index of the created reply.spec
- The reply specification.- Returns:
- The created reply.
-
doDetach
Creates a new detached manager.- Returns:
- The new manager.
-
detach
Description copied from interface:ReplyManager
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.
ReplyManager.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
ReplyManager.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).
- Specified by:
detach
in interfaceReplyManager
- Returns:
- A new detached manager. May result in an
IllegalStateException
if the manager detects that switching to a detached manager on the current state would cause an error or timeout later.
-
defer
Description copied from interface:ReplyManager
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.
- Specified by:
defer
in interfaceReplyManager
- Returns:
- A Mono that completes once deferral is complete.
-
add
Description copied from interface:ReplyManager
Sends a new reply.- Specified by:
add
in interfaceReplyManager
- Parameters:
spec
- The reply specification.- Returns:
- The created reply.
-
get
public Reply get(@org.checkerframework.checker.index.qual.NonNegative int index) throws IndexOutOfBoundsException Description copied from interface:ReplyManager
Retrieves a reply.- Specified by:
get
in interfaceReplyManager
- Parameters:
index
- The reply index.- Returns:
- The reply.
- Throws:
IndexOutOfBoundsException
- if there is no reply with that index.
-