Package io.github.unknowncoder56.javaslc
Class MessageContext
java.lang.Object
io.github.unknowncoder56.javaslc.MessageContext
- Direct Known Subclasses:
CommandContext
A class to create a context object which contains details about the message like message text, owner (author), server ID and
Bot instance.-
Constructor Summary
ConstructorsConstructorDescriptionMessageContext(com.google.gson.JsonObject message, String serverId, Bot bot) Constructor to create an instance of the class for a message. -
Method Summary
Modifier and TypeMethodDescriptiongetBot()Gets theBotwhich received the message.getOwner()Gets the message owner.Gets the server ID of the server where the message was sent.getText()Gets the message text.This method sends a message text to a server directly from where the message originated.
-
Constructor Details
-
MessageContext
Constructor to create an instance of the class for a message.- Parameters:
message- The message JSON retrieved from the SLChat API.serverId- The ID of the server where the message was sent.bot- TheBotinstance receiving the message event.
-
-
Method Details
-
send
This method sends a message text to a server directly from where the message originated. This method will throw aRuntimeExceptionif the bot is not in the server. To fix it, add it to the server withBot.join(String).- Parameters:
text- The message text to send.- Returns:
- A
CompletableFuturethat will be completed when the message is sent. - See Also:
-
getText
Gets the message text.- Returns:
- The message text.
-
getOwner
Gets the message owner.- Returns:
- The
Userinstance of the owner.
-
getServerId
Gets the server ID of the server where the message was sent.- Returns:
- The server ID of the server where the message was sent.
-
getBot
Gets theBotwhich received the message.- Returns:
- The
Botwhich received the message.
-