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 content, 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
-
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 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 a server withBot.join(String).- Parameters:
message- The message to send.- Returns:
- A
CompletableFuturethat will be completed when the message is sent. - See Also:
-
getContent
Gets the message content.- Returns:
- The message content.
-
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.
-