Table of Contents

Interface IChatCommand

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll
public interface IChatCommand
Extension Methods

Properties

AdditionalInformation

Get the detailed description of this command

string AdditionalInformation { get; }

Property Value

string

Aliases

Aliases for this command or subcommand

List<string> Aliases { get; }

Property Value

List<string>

AllSubcommands

Dictionary<string, IChatCommand> AllSubcommands { get; }

Property Value

Dictionary<string, IChatCommand>

CallSyntax

Get a string showing how to call this command or subcommand

string CallSyntax { get; }

Property Value

string

CallSyntaxUnformatted

string CallSyntaxUnformatted { get; }

Property Value

string

CommandPrefix

Get the prefix of this command

string CommandPrefix { get; }

Property Value

string

Description

Get the description of this command

string Description { get; }

Property Value

string

Examples

Get the examples of this command

string[] Examples { get; }

Property Value

string[]

FullName

Name of this command plus parent command names

string FullName { get; }

Property Value

string

Incomplete

True if either name or privilege has not been set

bool Incomplete { get; }

Property Value

bool

this[string]

Retrieve subcommand

IChatCommand this[string name] { get; }

Parameters

name string

Property Value

IChatCommand

Name

Name of this command

string Name { get; }

Property Value

string

RootAliases

RootAliases for this command or subcommand

List<string> RootAliases { get; }

Property Value

List<string>

Subcommands

IEnumerable<IChatCommand> Subcommands { get; }

Property Value

IEnumerable<IChatCommand>

Methods

AddParameterSyntax(StringBuilder, string)

Add text listing the parameters

void AddParameterSyntax(StringBuilder sb, string indent)

Parameters

sb StringBuilder
indent string

AddSyntaxExplanation(StringBuilder, string)

Add text explaining the form and interpretation of some of the more complex parameter types

void AddSyntaxExplanation(StringBuilder sb, string indent)

Parameters

sb StringBuilder
indent string

BeginSubCommand(string)

Define/Modify a subcommnad. Returns a new subcommand instance.

IChatCommand BeginSubCommand(string name)

Parameters

name string

Returns

IChatCommand

BeginSubCommands(params string[])

Define/Modify multiple subcommands. Returns a new subcommand instance.

IChatCommand BeginSubCommands(params string[] name)

Parameters

name string[]

Returns

IChatCommand

EndSubCommand()

Leave current subcommand. Returns parent command instance.

IChatCommand EndSubCommand()

Returns

IChatCommand

Execute(TextCommandCallingArgs, Action<TextCommandResult>)

Manually execute this command

void Execute(TextCommandCallingArgs callargs, Action<TextCommandResult> onCommandComplete = null)

Parameters

callargs TextCommandCallingArgs
onCommandComplete Action<TextCommandResult>

GetCallSyntax(string, bool)

string GetCallSyntax(string alias, bool isRootAlias = false)

Parameters

alias string
isRootAlias bool

Returns

string

GetCallSyntaxUnformatted(string, bool)

string GetCallSyntaxUnformatted(string alias, bool isRootAlias = false)

Parameters

alias string
isRootAlias bool

Returns

string

GetFullName(string, bool)

string GetFullName(string alias, bool isRootAlias = false)

Parameters

alias string
isRootAlias bool

Returns

string

GetFullSyntaxConsole(Caller)

string GetFullSyntaxConsole(Caller caller)

Parameters

caller Caller

Returns

string

GetFullSyntaxHandbook(Caller, string, bool)

string GetFullSyntaxHandbook(Caller caller, string indent = "", bool isRootAlias = false)

Parameters

caller Caller
indent string
isRootAlias bool

Returns

string

HandleWith(OnCommandDelegate)

Define method to be called when the command is executed

IChatCommand HandleWith(OnCommandDelegate handler)

Parameters

handler OnCommandDelegate

Returns

IChatCommand

IgnoreAdditionalArgs()

IChatCommand IgnoreAdditionalArgs()

Returns

IChatCommand

IsAvailableTo(Caller)

Confirm whether the specified caller has the required privilege for this command

bool IsAvailableTo(Caller caller)

Parameters

caller Caller

Returns

bool

RequiresPlayer()

This command can only be run if the caller is a player

IChatCommand RequiresPlayer()

Returns

IChatCommand

RequiresPrivilege(string)

Define the required privilege to run this command / subcommand

IChatCommand RequiresPrivilege(string privilege)

Parameters

privilege string

Returns

IChatCommand

Validate()

Optional validation step that ensures that all the command and all its subcommands has a name, handler, privilege and description defined

void Validate()

WithAdditionalInformation(string)

Set additional detailed command description, for command-specific help

IChatCommand WithAdditionalInformation(string detail)

Parameters

detail string

Returns

IChatCommand

WithAlias(params string[])

Registers alternative names for this command

IChatCommand WithAlias(params string[] name)

Parameters

name string[]

Returns

IChatCommand

WithArgs(params ICommandArgumentParser[])

Define command arguments, you'd usually want to use one of the parsers supplied from from capi.ChatCommands.Parsers

IChatCommand WithArgs(params ICommandArgumentParser[] args)

Parameters

args ICommandArgumentParser[]

Returns

IChatCommand

WithDescription(string)

Set command description

IChatCommand WithDescription(string description)

Parameters

description string

Returns

IChatCommand

WithExamples(params string[])

Define one ore more examples on how this command can be executed

IChatCommand WithExamples(params string[] examaples)

Parameters

examaples string[]

Returns

IChatCommand

WithName(string)

Sets the command name

IChatCommand WithName(string name)

Parameters

name string

Returns

IChatCommand

WithPreCondition(CommandPreconditionDelegate)

If return value is error, command cannot be executed

IChatCommand WithPreCondition(CommandPreconditionDelegate p)

Parameters

p CommandPreconditionDelegate

Returns

IChatCommand

WithRootAlias(string)

Registers an alternative name for this command, always at the root level, i.e. /name

IChatCommand WithRootAlias(string name)

Parameters

name string

Returns

IChatCommand