Commander class Null safety

Lightweight command framework. Doesn't use dart:mirrors and can be used in browser. While constructing specify prefix which is string with prefix or implement PrefixHandlerFunction for more fine control over where and in what conditions commands are executed.

Allows to specify callbacks which are executed before and after command - also on per command basis. beforeCommandHandler callbacks are executed only command exists and is matched with message content.

Mixed in types

Constructors

Commander(Nyxx client, {String? prefix, PrefixHandlerFunction? prefixHandler, PassHandlerFunction? beforeCommandHandler, AfterHandlerFunction? afterCommandHandler, LoggerHandlerFunction? loggerHandlerFunction, CommandExecutionError? commandExecutionError})
Either prefix or prefixHandler must be specified otherwise program will exit. Allows to specify additional beforeCommandHandler executed before main command callback, and afterCommandHandler executed after main command callback.

Properties

commands List<CommandEntity>
Returns unmodifiable list of registered commands.
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

getPrefixForMessage(Message message) FutureOr<String?>
Resolves prefix for given message. Returns null if there is no prefix for given message which means command wouldn't execute in given context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
registerCommand(String commandName, CommandHandlerFunction commandHandler, {PassHandlerFunction? beforeHandler, AfterHandlerFunction? afterHandler}) → void
Registers command with given commandName. Allows to specify command specific before and after command execution callbacks
registerCommandEntity(CommandEntity entity) → void
Registers CommandEntity within context of this instance. Throws error if there is command with same name as provided.
inherited
registerCommandGroup(CommandGroup commandGroup) → void
Registers command as implemented CommandEntity class
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited