Class ConsoleCommandAttribute
Marks an instance method on an ISystem as a console command. The method is invoked when a command is sent via the console (from a player or server).
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ConsoleCommandAttribute : Attribute, ICommandAttribute
- Inheritance
-
ConsoleCommandAttribute
- Implements
- Inherited Members
Remarks
The signature can be:
(ConsoleCommandDispatchContext context, [args...])- if the first parameter is ConsoleCommandDispatchContext, it is provided automatically([args...])- if no ConsoleCommandDispatchContext first parameter, all parameters are treated as regular parsed parameters- subsequent parameters are parsed from the console input via ICommandParameterParser
- Return type may be void, bool, Task, or Task<TResult> where T is bool. Unlike player commands, console commands do NOT have permission checking.
Constructors
ConsoleCommandAttribute()
Initializes a new instance with the command name inferred from the method name (lowercased, trailing "Command" stripped).
public ConsoleCommandAttribute()
ConsoleCommandAttribute(string)
Initializes a new instance with the explicit command name.
public ConsoleCommandAttribute(string name)
Parameters
namestring
Properties
Name
The command name (optional; derives from method name if not specified).
public string? Name { get; set; }