Constructs a new command group. By default, this constructor will register message events and listen for messages that match commands added to the command group.
The options for this command group.
Attaches the command executors provided.
For more examples, see discord.command.handler.
Generally it is preferred to use on, raw and subcommand depending on how you wish to structure your module. Attach is generally more useful when you are importing un-attached commands from various modules, whereas on & company are useful if you want to define your command handlers in-line.
An object, keyed by the name that the command executor will use.
Determines if the command group will execute given the supplied message, without executing the command.
Note: Use discord.command.CommandGroup.handleMessage to execute a command within the CommandGroup.
Registers a command that will run for any un-matched commands that match the command group's prefix(es) and the arguments specified.
A function that collects the argument types this command expects.
A function to be ran when command validation succeeds and the command should be executed.
Options for this default handler.
Registers a command that will run for any un-matched commands that match the command group's prefix(es).
All text proceeding the command name is passed to the handler in the "args" parameter as a string.
A function to be ran when command validation succeeds and the command should be executed.
Options for this default handler.
Manually executes the command group given a discord.Message. Useful if you specify { register: false }
when instantiating a new CommandGroup.
If the message is not to be handled by this command group (given the command prefix and command name) the Promise will resolve as false
.
If the message was otherwise handled and executed, it will otherwise resolve true
.
Note: Use discord.command.CommandGroup.checkMessage to check (without executing) if the CommandGroup will execute for the given message.
true
if a command was handled and executed successfully. The function will throw if the command handler errors.
Registers a command that expects arguments.
If argument parsing/validation fails, an error will be returned to the user and the handler will not run.
Creates a script that will have a command that returns a number that has been multiplied by 2, as !double N
, where !double 4
would output 8
const commandGroup = new discord.command.CommandGroup();
commandGroup.on(
'double',
(ctx) => ({ n: ctx.integer() }),
(message, { n }) => message.reply(`${n * 2}`)
);
A string containing the name of the command, or an object with more options (including filters, description, etc).
A function that collects the argument types this command expects.
A function to be ran when command validation succeeds and the command should be executed.
Registers a command that accepts any or no arguments.
All text proceeding the command name is passed to the handler in the "args" parameter as a string.
Creates a script that will reply with pong!
when !ping
is said in chat.
const commandGroup = new discord.command.CommandGroup();
commandGroup.raw("ping", message => message.reply("pong!"));
A string containing the name of the command, or an object with more options (including filters, description, etc).
A function to be ran when command validation succeeds and the command should be executed.
Registers a command that expects arguments.
Registers a command that expects no arguments.
Sets the filter(s) to be used for this command group. All child commands will use these filters.
Note: Replaces any filters set previously.
The filter composition to use for this command group.
Registers a command that may be followed by additional nested command groups.
This is useful to further organize and group commands within a single parent command group.
Sub-command groups are just like Command Groups, and will require filters of all parent sub-commands to be passed before executing any sub-commands.
Creates a script that will have the following commands:
!lights on
!lights off
const commandGroup = new discord.command.CommandGroup();
commandGroup.subcommand("lights", subCommandGroup => {
subCommandGroup.raw("on", m => m.reply("lights on turned on!"));
subCommandGroup.raw("off", m => m.reply("lights turned off!"));
});
A string containing the name of the command, or an object with more options. See discord.command.ICommandGroupOptions. The name
property must be present, specifying the name of the subcommand-group. Sub-command groups may not be automatically registered, so the register
property must not be set.
A CommandGroup instance (must not be previously registered) or a function which passes a nested CommandGroup as the first parameter.
Deprecated - attach the subcommand group using attach instead.
Creates, registers and returns a sub-command group.
This command is an alternate form of subcommand, that lets capture the sub-command's CommandGroup. For more on sub-commands, see the subcommand docs.
Creates a script that will have the following commands:
!lights on
!lights off
const commandGroup = new discord.command.CommandGroup();
const subCommandGroup = commandGroup.subcommandGroup("lights");
subCommandGroup.raw("on", m => m.reply("lights on turned on!"));
subCommandGroup.raw("off", m => m.reply("lights turned off!"));
An object containing the command group's options. Register is not able to be set, as the command group is implicitly registered as a sub-command for this command group.
Generated using TypeDoc
Command groups contain categories of logically separated groups of commands.
Command Groups may specify filters that apply to all commands added to the group.
Commands must be added to command groups via one of the registration methods available.