Class MessageReplyManager
java.lang.Object
dev.sympho.modular_commands.impl.context.MessageReplyManager
- All Implemented Interfaces:
ReplyManager
Reply manager for message-based commands.
- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
Whether replies are private by default.protected final boolean
Whether the first reply is deferred.The sent replies.protected final dev.sympho.reactor_utils.concurrent.ReactiveLock
The lock for send ordering.Fields inherited from interface dev.sympho.modular_commands.api.command.reply.ReplyManager
NO_RESPONSE_ERROR
-
Constructor Summary
ConstructorsConstructorDescriptionMessageReplyManager
(Message original, Mono<MessageChannel> publicChannel, @Nullable Mono<PrivateChannel> privateChannel, boolean defaultPrivate, boolean deferred) Creates a new manager. -
Method Summary
Modifier and TypeMethodDescriptionadd
(CommandReplySpec spec) Sends a new reply.get
(int index) Retrieves a reply.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).send
(int index, CommandReplySpec spec) 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. -
deferred
protected final boolean deferredWhether 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 benull
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
Sends a new reply.- Parameters:
index
- The index of the created reply.spec
- The reply specification.- Returns:
- The created reply.
-
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
Description copied from interface:ReplyManager
Sends a new reply.- Specified by:
add
in interfaceReplyManager
- Parameters:
spec
- The reply specification.- Returns:
- The created reply.
-
get
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.
-