Class MessageContext

java.lang.Object
io.github.unknowncoder56.javaslc.MessageContext
Direct Known Subclasses:
CommandContext

public class MessageContext extends Object
A class to create a context object which contains details about the message like message content, owner (author), server ID and Bot instance.
  • Constructor Details

    • MessageContext

      public MessageContext(com.google.gson.JsonObject message, String serverId, Bot bot)
      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 - The Bot instance receiving the message event.
  • Method Details

    • send

      public CompletableFuture<Void> send(String message)
      This method sends a message to a server directly from where the message originated. This method will throw a RuntimeException if the bot is not in the server. To fix it add it to a server with Bot.join(String).
      Parameters:
      message - The message to send.
      Returns:
      A CompletableFuture that will be completed when the message is sent.
      See Also:
    • getContent

      public String getContent()
      Gets the message content.
      Returns:
      The message content.
    • getOwner

      public User getOwner()
      Gets the message owner.
      Returns:
      The User instance of the owner.
    • getServerId

      public String 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

      public Bot getBot()
      Gets the Bot which received the message.
      Returns:
      The Bot which received the message.