Class CommandAttribute
- Namespace
- Signal.Application.Commands
- Assembly
- Signal.Application.dll
Declares a command: on a public method of a CommandModule, or on an ICommand class deriving from CommandBase (which then reads its metadata from this attribute).
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class CommandAttribute : Attribute
- Inheritance
-
CommandAttribute
- Inherited Members
Examples
[Command("roll", Aliases = ["dice"], Description = "Rolls a die")]
public Task RollAsync(int sides = 6) => ReplyAsync($"{Random.Shared.Next(1, sides + 1)}");
Constructors
CommandAttribute(string)
Declares a command: on a public method of a CommandModule, or on an ICommand class deriving from CommandBase (which then reads its metadata from this attribute).
public CommandAttribute(string name)
Parameters
namestringThe command name, typed after the prefix (e.g.
pingfor/ping). Must not contain whitespace.
Examples
[Command("roll", Aliases = ["dice"], Description = "Rolls a die")]
public Task RollAsync(int sides = 6) => ReplyAsync($"{Random.Shared.Next(1, sides + 1)}");
Properties
Aliases
Alternative names. Names and aliases must be unique across all commands.
public string[] Aliases { get; set; }
Property Value
- string[]
Description
One-line description shown by the help command.
public string? Description { get; set; }
Property Value
Hidden
Hide the command from the help listing (it can still be executed and described).
public bool Hidden { get; set; }
Property Value
Name
The command name.
public string Name { get; }
Property Value
Usage
Custom usage text (without prefix). Generated from the parameters when omitted.
public string? Usage { get; set; }