addCommand method
- covariant CommandRegisterable<
ChatContext> command
override
Add a command to this group.
A command can be added to a group at most once; trying to do so will result in a CommandsError being thrown.
Implementation
@override
void addCommand(CommandRegisterable<ChatContext> command) {
if (command is! ChatCommandComponent) {
throw CommandsError(
'All child commands of chat groups or commands must implement IChatCommandComponent');
}
if (resolvedOptions.type != CommandType.textOnly) {
if (command.hasSlashCommand ||
(command is ChatCommand && command.resolvedOptions.type != CommandType.textOnly)) {
throw CommandRegistrationError('Cannot nest Slash commands!');
}
}
super.addCommand(command);
}