Package io.github.unknowncoder56.javaslc
Class CommandContext
java.lang.Object
io.github.unknowncoder56.javaslc.MessageContext
io.github.unknowncoder56.javaslc.CommandContext
A class to create a context object which contains details about the command like message, owner (author), server ID,
Bot instance, command name and command arguments.-
Constructor Summary
ConstructorsConstructorDescriptionCommandContext(com.google.gson.JsonObject message, String serverId, Bot bot, String command) Constructor to create an instance of the class for a command without arguments.CommandContext(com.google.gson.JsonObject message, String serverId, Bot bot, String command, String[] arguments) Constructor to create an instance of the class for a command with arguments. -
Method Summary
Modifier and TypeMethodDescriptionString[]Gets the array of the arguments supplied with the command.Gets the command name of the command received.Methods inherited from class io.github.unknowncoder56.javaslc.MessageContext
getBot, getOwner, getServerId, getText, send
-
Constructor Details
-
CommandContext
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- TheBotinstance receiving the message event.command- The command name of the command issued by the user.
-
CommandContext
public CommandContext(com.google.gson.JsonObject message, String 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- TheBotinstance 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
Gets the command name of the command received. Note: The command name does not contain the bot prefix.- Returns:
- The command name of the command received.
-
getArguments
Gets the array of the arguments supplied with the command.- Returns:
- The array of the arguments supplied with the command.
-