Class CommandBase
- Namespace
- Signal.Application.Commands
- Assembly
- Signal.Application.dll
Base class for class-based commands. Metadata defaults to the CommandAttribute on the class and every member can be overridden.
public abstract class CommandBase : ICommand
- Inheritance
-
CommandBase
- Implements
- Inherited Members
Examples
[Command("ping", Description = "Checks that the bot is alive")]
public sealed class PingCommand : CommandBase
{
public override Task ExecuteAsync(CommandContext context, CancellationToken ct) =>
context.ReplyAsync("pong", cancellationToken: ct);
}
Properties
Aliases
Alternative names.
public virtual IReadOnlyList<string> Aliases { get; }
Property Value
Description
One-line description for the help listing.
public virtual string? Description { get; }
Property Value
Hidden
Whether the command is hidden from the help listing.
public virtual bool Hidden { get; }
Property Value
Name
The command name (typed after the prefix).
public virtual string Name { get; }
Property Value
Exceptions
- InvalidOperationException
Neither overridden nor declared through CommandAttribute.
Usage
Usage text without prefix, e.g. ban <number> [reason...].
public virtual string? Usage { get; }
Property Value
Methods
ExecuteAsync(CommandContext, CancellationToken)
Executes the command.
public abstract Task ExecuteAsync(CommandContext context, CancellationToken cancellationToken)
Parameters
contextCommandContextThe command context (message, arguments, services, reply helpers).
cancellationTokenCancellationTokenCancelled when the host shuts down.
Returns
- Task
A task that completes when the command has finished.