Table of Contents

Class CommandDispatcher

Namespace
Uncreated.Warfare.Interaction.Commands
Assembly
Uncreated.Warfare.dll
public class CommandDispatcher : IDisposable, IHostedService, IEventListener<PlayerLeft>
Inheritance
CommandDispatcher
Implements
Inherited Members

Constructors

CommandDispatcher(IServiceProvider)

public CommandDispatcher(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

Properties

Commands

public IReadOnlyList<CommandInfo> Commands { get; }

Property Value

IReadOnlyList<CommandInfo>

Parser

public CommandParser Parser { get; }

Property Value

CommandParser

Methods

AssertPermissions(CommandInfo, CommandContext, CancellationToken)

Throw a CommandContext if a command doesn't have permission to be ran by ctx.

public static UniTask AssertPermissions(CommandInfo command, CommandContext ctx, CancellationToken token = default)

Parameters

command CommandInfo
ctx CommandContext
token CancellationToken

Returns

UniTask

ExecuteCommandAsync(CommandInfo, ICommandUser, string[], CommandFlagInfo[], string, List<CommandWaitTask>?, CancellationToken)

Execute a parsed command.

public UniTask ExecuteCommandAsync(CommandInfo command, ICommandUser user, string[] args, CommandFlagInfo[] flags, string originalMessage, List<CommandWaitTask>? waitTasks, CancellationToken token = default)

Parameters

command CommandInfo
user ICommandUser
args string[]
flags CommandFlagInfo[]
originalMessage string
waitTasks List<CommandWaitTask>
token CancellationToken

Returns

UniTask

FindCommand(string)

Find information about a command by name.

public CommandInfo? FindCommand(string search)

Parameters

search string

Returns

CommandInfo

FindCommand(Type)

Find information about a command by name.

public CommandInfo? FindCommand(Type commandType)

Parameters

commandType Type

Returns

CommandInfo

WaitForCommand(Type, TimeSpan, CommandWaitOptions, CancellationToken)

Wait for a commandType command to be executed by any user.

public CommandWaitTask WaitForCommand(Type commandType, TimeSpan timeout = default, CommandWaitOptions options = CommandWaitOptions.Default, CancellationToken token = default)

Parameters

commandType Type
timeout TimeSpan
options CommandWaitOptions
token CancellationToken

Returns

CommandWaitTask

WaitForCommand(Type, ICommandUser, TimeSpan, CommandWaitOptions, CancellationToken)

Wait for a commandType command to be executed by user.

public CommandWaitTask WaitForCommand(Type commandType, ICommandUser user, TimeSpan timeout = default, CommandWaitOptions options = CommandWaitOptions.Default, CancellationToken token = default)

Parameters

commandType Type
user ICommandUser
timeout TimeSpan
options CommandWaitOptions
token CancellationToken

Returns

CommandWaitTask

WaitForCommand(CommandInfo, TimeSpan, CommandWaitOptions, CancellationToken)

Wait for a commandType command to be executed by any user.

public CommandWaitTask WaitForCommand(CommandInfo commandType, TimeSpan timeout = default, CommandWaitOptions options = CommandWaitOptions.Default, CancellationToken token = default)

Parameters

commandType CommandInfo
timeout TimeSpan
options CommandWaitOptions
token CancellationToken

Returns

CommandWaitTask

WaitForCommand(CommandInfo, ICommandUser, TimeSpan, CommandWaitOptions, CancellationToken)

Wait for a commandType command to be executed by user.

public CommandWaitTask WaitForCommand(CommandInfo commandType, ICommandUser user, TimeSpan timeout = default, CommandWaitOptions options = CommandWaitOptions.Default, CancellationToken token = default)

Parameters

commandType CommandInfo
user ICommandUser
timeout TimeSpan
options CommandWaitOptions
token CancellationToken

Returns

CommandWaitTask