register method
void
register(
- List<MineralCommandContract> commands
)
Implementation
@override
void register (List<MineralCommandContract> commands) {
for (final mineralCommand in List<MineralCommand>.from(commands)) {
final command = mineralCommand.command;
_commands.putIfAbsent(mineralCommand.command.label, () => mineralCommand.command);
final Scope scope = command.scope ?? Scope.guild;
if (command.subcommands.isEmpty && command.groups.isEmpty) {
if(scope.isGuild) {
_guildHandlers.putIfAbsent(command.label, () => mineralCommand.handle);
} else {
_globalHandlers.putIfAbsent(command.label, () => mineralCommand.handle);
}
}
if (command.subcommands.isNotEmpty) {
_registerSubCommands(mineralCommand.command.label, scope, command.subcommands);
}
if (command.groups.isNotEmpty) {
for (final group in command.groups) {
_registerSubCommands(mineralCommand.command.label + '.' + group.label, command.scope ?? Scope.guild, group.subcommands);
}
}
_commands.putIfAbsent(mineralCommand.command.label, () => mineralCommand.command);
}
}