registerCommandEntity method Null safety
- ICommandEntity entity
inherited
Registers CommandEntity
within context of this instance. Throws error if there is command with same name as provided.
Implementation
@override
void registerCommandEntity(ICommandEntity entity) {
if (commandEntities.any((element) => element.isEntityName(entity.name))) {
throw Exception("Command name should be unique! There is already command with name: ${entity.name}}");
}
if (entity is ICommandGroup && entity.name.isEmpty && entity.aliases.isNotEmpty) {
throw Exception("Command group cannot have aliases if its name is empty! Provided aliases: [${entity.aliases.join(", ")}]");
}
commandEntities.add(entity);
}