Class CommandDispatcher
Parses a raw command line and runs the matching command. Input must start with Prefix
(default /); the prefix is stripped, the rest split on whitespace, the command looked up, its
permission enforced against the sender, then executed. Sync command bodies run inline; async command
bodies are awaited. Unknown commands, permission denials and execution errors are reported back
through the sender.
public sealed class CommandDispatcher
- Inheritance
-
CommandDispatcher
- Inherited Members
Constructors
CommandDispatcher(ICommandRegistry, string)
Parses a raw command line and runs the matching command. Input must start with Prefix
(default /); the prefix is stripped, the rest split on whitespace, the command looked up, its
permission enforced against the sender, then executed. Sync command bodies run inline; async command
bodies are awaited. Unknown commands, permission denials and execution errors are reported back
through the sender.
public CommandDispatcher(ICommandRegistry registry, string prefix = "/")
Parameters
registryICommandRegistryprefixstring
Properties
Prefix
The leading marker for commands.
public string Prefix { get; }
Property Value
Methods
DispatchAsync(ICommandSender, string, CommandExecutor, CancellationToken)
Run line using a caller-supplied executable command runner.
public ValueTask<bool> DispatchAsync(ICommandSender sender, string line, CommandExecutor executor, CancellationToken cancellationToken = default)
Parameters
senderICommandSenderlinestringexecutorCommandExecutorcancellationTokenCancellationToken
Returns
DispatchAsync(ICommandSender, string, CancellationToken)
Run line as a command. Returns false when it is not a command.
public ValueTask<bool> DispatchAsync(ICommandSender sender, string line, CancellationToken cancellationToken = default)
Parameters
senderICommandSenderlinestringcancellationTokenCancellationToken