Table of Contents

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

IReadOnlyList<string>

Description

One-line description for the help listing.

public virtual string? Description { get; }

Property Value

string

Hidden

Whether the command is hidden from the help listing.

public virtual bool Hidden { get; }

Property Value

bool

Name

The command name (typed after the prefix).

public virtual string Name { get; }

Property Value

string

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

string

Methods

ExecuteAsync(CommandContext, CancellationToken)

Executes the command.

public abstract Task ExecuteAsync(CommandContext context, CancellationToken cancellationToken)

Parameters

context CommandContext

The command context (message, arguments, services, reply helpers).

cancellationToken CancellationToken

Cancelled when the host shuts down.

Returns

Task

A task that completes when the command has finished.