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
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.api.command.ReplyManager
ReplyManager.EphemeralType -
Field Summary
Fields inherited from interface dev.sympho.modular_commands.api.command.ReplyManager
NO_RESPONSE_ERROR -
Constructor Summary
ConstructorsConstructorDescriptionMessageReplyManager(Message original, MessageChannel publicChannel, PrivateChannel privateChannel) Creates a new manager. -
Method Summary
Modifier and TypeMethodDescriptionadd(MessageCreateSpec spec) Adds a reply to the chain (either initial or followup).defer()Defers initial response, indicating to the user that the response is being processed.delete(int index) Deletes a reply.edit(int index, MessageEditSpec spec) Edits a 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).reply(MessageCreateSpec spec) Sends an initial reply.setDeleteDelay(Duration delay) Sets the delay before deleting new replies, if they aretimed.setEphemeral(ReplyManager.EphemeralType ephemeral) Sets whether new replies should be ephemeral.setPrivate(boolean priv) Sets whether new replies should be sent in DMs.
-
Constructor Details
-
MessageReplyManager
@SideEffectFree public MessageReplyManager(Message original, MessageChannel publicChannel, PrivateChannel privateChannel) 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.
-
-
Method Details
-
setPrivate
Description copied from interface:ReplyManagerSets whether new replies should be sent in DMs.Existing replies are not affected.
- Specified by:
setPrivatein interfaceReplyManager- Parameters:
priv- If new replies should be sent in a private channel.- Returns:
- This.
-
setEphemeral
Description copied from interface:ReplyManagerSets whether new replies should be ephemeral.Existing replies are not affected.
- Specified by:
setEphemeralin interfaceReplyManager- Parameters:
ephemeral- The ephemeral type for new replies.- Returns:
- This.
-
setDeleteDelay
Description copied from interface:ReplyManagerSets the delay before deleting new replies, if they aretimed.Existing replies are not affected.
- Specified by:
setDeleteDelayin interfaceReplyManager- Parameters:
delay- The delay.- Returns:
- This.
-
defer
Description copied from interface:ReplyManagerDefers initial response, indicating to the user that the response is being processed.- Specified by:
deferin interfaceReplyManager- Returns:
- A Mono that completes after deferral is processed.
-
reply
Description copied from interface:ReplyManagerSends an initial reply.- Specified by:
replyin interfaceReplyManager- Parameters:
spec- The message specification.- Returns:
- A Mono that completes after the reply is sent.
- Throws:
IllegalStateException- if an initial reply was already made.
-
add
Description copied from interface:ReplyManagerAdds a reply to the chain (either initial or followup).- Specified by:
addin interfaceReplyManager- Parameters:
spec- The message specification.- Returns:
- The created message and its index.
-
edit
public Mono<Message> edit(int index, MessageEditSpec spec) throws IndexOutOfBoundsException, IllegalStateException Description copied from interface:ReplyManagerEdits a reply.- Specified by:
editin interfaceReplyManager- Parameters:
index- The reply index.spec- The edit specification.- Returns:
- The edited message. Fails with an
IllegalStateExceptionif the initial reply was deleted. - Throws:
IndexOutOfBoundsException- if there is no reply with that index.IllegalStateException
-
get
Description copied from interface:ReplyManagerRetrieves a reply.- Specified by:
getin interfaceReplyManager- Parameters:
index- The reply index.- Returns:
- The reply. Fails with an
IllegalStateExceptionif the reply was deleted. - Throws:
IndexOutOfBoundsException- if there is no reply with that index.IllegalStateException
-
delete
Description copied from interface:ReplyManagerDeletes a reply.Note that this does not change the index of other replies within this manager.
- Specified by:
deletein interfaceReplyManager- Parameters:
index- The reply index.- Returns:
- A Mono that completes when the reply is deleted. Fails with an
IllegalStateExceptionif the reply was already deleted. - Throws:
IndexOutOfBoundsException- if there is no reply with that index.IllegalStateException
-
longTerm
Description copied from interface:ReplyManagerObtains 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.
- Specified by:
longTermin interfaceReplyManager- Returns:
- The long-term manager.
-