-
-
Notifications
You must be signed in to change notification settings - Fork 2
Argument
Discord allows you to specify multiple opportunities for one argument. This is useful when the command has multiple functionality.
To add argument to the command: Command#addArgument(Argument...)
Command is like a tree, that means every argument is a branch of the tree. Arguments with SUB_COMMAND
or SUB_COMMAND_GROUP
type can have more branches (aka arguments), but not every type of arguments. Argument can be added to sub commands with SubArgument#addArgument(Argument)
One of the main argument types. The SubArgument<T, R>
is an abstract class with two generic type. The T
must be an extension of Argument<O>
class, since it tells which type of argument can be added to the argument. The R
is the result type of the argument.
According to Discord's limitations, not every type of argument can contain any type of argument. In JCommands there are 2 types of argument that can contain other arguments:
Argument | Description | Accepted type of argument |
---|---|---|
GroupArgument | Used to group SUB_COMMAND arguments, since SUB_COMMAND arguments cannot be nested. |
ConstantArgument |
ConstantArgument | Only these can contain arguments that accepts some type of user input |
InputArgument<I, O> |
In the following example there is a command that has two different arguments. In the second argument the user can choose between the two different values.
GroupArgument groupArgument = new GroupArgument("which", "Which one do you want?");
groupArgument.addArgument(new ConstantArgument("this", "This is this"));
groupArgument.addArgument(new ConstantArgument("that", "This is that"));
command.addArgument(groupArgument);
Valid usage of the command with the arguments: /command which this
and /command which that