Class CommandContext

java.lang.Object
io.github.unknowncoder56.javaslc.MessageContext
io.github.unknowncoder56.javaslc.CommandContext

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

    • CommandContext

      public CommandContext(com.google.gson.JsonObject message, long serverId, Bot bot, String command)
      Constructor to create an instance of the class for a command without arguments.
      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.
      command - The command name of the command issued by the user.
    • CommandContext

      public CommandContext(com.google.gson.JsonObject message, long serverId, Bot bot, String command, String[] arguments)
      Constructor to create an instance of the class for a command with arguments.
      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.
      command - The command name of the command issued by the user.
      arguments - An array of the command arguments.
  • Method Details

    • getCommand

      public String getCommand()
      Gets the command name of the command received.
      Returns:
      The command name of the command received.
    • getArguments

      public String[] getArguments()
      Gets the array of the arguments supplied with the command.
      Returns:
      The array of the arguments supplied with the command.