register method

  1. @override
void register(
  1. List<MineralCommandContract> commands
)

Implementation

@override
void register (List<MineralCommandContract> commands) {
  for (final command in List<MineralCommand>.from(commands)) {
    _commands.putIfAbsent(command.label.uid, () => command);

    if (command.subcommands.isNotEmpty) {
      _registerSubCommands(command.label.uid, command.scope ?? CommandScope.guild, command.subcommands, null);
    }

    if (command.groups.isNotEmpty) {
      for (final group in command.groups) {
        _registerSubCommands(command.label.uid, command.scope ?? CommandScope.guild, group.subcommands, group);
      }
    }

    if(command.groups.isEmpty && command.subcommands.isEmpty) {
      _handlers.putIfAbsent(command.label.uid, () => command);
    }
  }
}