Package io.manebot.chat
Interface ChatSender
-
- All Superinterfaces:
ChatMessageReceiver
- All Known Implementing Classes:
CommandSender
,DefaultChatSender
,DefaultCommandSender
public interface ChatSender extends ChatMessageReceiver
-
-
Method Summary
Modifier and Type Method Description boolean
begin()
Opens the command buffer.java.util.Collection<ChatMessage>
end()
Ends the command buffer.java.util.Collection<ChatMessage>
flush()
Flushes the buffer.Chat
getChat()
Gets the chat the message was sent in.default java.lang.String
getDisplayName()
Gets the display name of the command sender.PlatformUser
getPlatformUser()
Gets the platform user that is associated with this chat sender.default java.lang.String
getUsername()
Gets the username of the command sender.java.util.Collection<ChatMessage>
sendDetails(java.util.function.Consumer<CommandDetailsResponse.Builder> function)
Creates a details response to get to the command sender, opportunistically formatting as rich content.default <T> java.util.Collection<ChatMessage>
sendList(java.lang.Class<T> type, SearchResult<T> result, CommandListResponse.ListElementFormatter<T> formatter)
Constructs a list response on the given search object and associated chat sender.<T> java.util.Collection<ChatMessage>
sendList(java.lang.Class<T> type, java.util.function.Consumer<CommandListResponse.Builder<T>> function)
Creates a list response to get to the command sender, opportunistically formatting as rich content.default java.util.Collection<ChatMessage>
sendMessage(java.util.function.Consumer<ChatMessage.Builder> function)
Sends a message to the receiver.-
Methods inherited from interface io.manebot.chat.ChatMessageReceiver
canSendEmbeds, sendFormattedMessage, sendFormattedMessages, sendMessage, sendMessages, sendMessages, sendRawMessage, sendRawMessages
-
-
-
-
Method Detail
-
getPlatformUser
PlatformUser getPlatformUser()
Gets the platform user that is associated with this chat sender.- Returns:
- PlatformUser instance.
-
getUsername
default java.lang.String getUsername()
Gets the username of the command sender.
-
getDisplayName
default java.lang.String getDisplayName()
Gets the display name of the command sender.
-
getChat
Chat getChat()
Gets the chat the message was sent in.- Returns:
- Chat instance.
-
begin
boolean begin()
Opens the command buffer.- Returns:
- true if the buffer was opened, false if no changes were made.
-
end
java.util.Collection<ChatMessage> end()
Ends the command buffer.- Returns:
- ChatMessage generated.
-
flush
java.util.Collection<ChatMessage> flush()
Flushes the buffer.- Returns:
- ChatMessage generated.
-
sendMessage
default java.util.Collection<ChatMessage> sendMessage(java.util.function.Consumer<ChatMessage.Builder> function)
Description copied from interface:ChatMessageReceiver
Sends a message to the receiver.- Specified by:
sendMessage
in interfaceChatMessageReceiver
- Parameters:
function
- function to use to build the chat message.
-
sendList
<T> java.util.Collection<ChatMessage> sendList(java.lang.Class<T> type, java.util.function.Consumer<CommandListResponse.Builder<T>> function) throws CommandExecutionException
Creates a list response to get to the command sender, opportunistically formatting as rich content.- Type Parameters:
T
- List item type.- Parameters:
function
- Function providing a command response object from a builder.- Returns:
- CommandResponse object corresponding to the desired message; contains get() method to dispatch.
- Throws:
CommandExecutionException
-
sendList
default <T> java.util.Collection<ChatMessage> sendList(java.lang.Class<T> type, SearchResult<T> result, CommandListResponse.ListElementFormatter<T> formatter) throws CommandExecutionException
Constructs a list response on the given search object and associated chat sender. Has a default implementation for ease-of-use, via the virtual list accessor system, used for paged results where more results exist virtually outside the application (such as, in the case of a search). This is used to improve performance and lower overhead when searching over millions of rows, for example.- Type Parameters:
T
- List item type.- Parameters:
type
- List item type.result
- Search result object, obtained from a SearchHandler class.- Returns:
- CommandResponse object corresponding to the desired message; contains get() method to dispatch.
- Throws:
CommandExecutionException
-
sendDetails
java.util.Collection<ChatMessage> sendDetails(java.util.function.Consumer<CommandDetailsResponse.Builder> function) throws CommandExecutionException
Creates a details response to get to the command sender, opportunistically formatting as rich content. Details are formatted as such: ObjectName "ObjectKey" details: Key: value Key: [value1,value2,value3]- Parameters:
function
- Function providing a command response object from a builder.- Returns:
- CommandResponse object corresponding to the desired message; contains get() method to dispatch.
- Throws:
CommandExecutionException
-
-