Table of Contents

Class CommandDispatcher

Namespace
Shard.Modding.SDK.Command
Assembly
Shard.Modding.SDK.dll

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

registry ICommandRegistry
prefix string

Properties

Prefix

The leading marker for commands.

public string Prefix { get; }

Property Value

string

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

sender ICommandSender
line string
executor CommandExecutor
cancellationToken CancellationToken

Returns

ValueTask<bool>

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

sender ICommandSender
line string
cancellationToken CancellationToken

Returns

ValueTask<bool>