Skip to content

SlashCommands

Category: Commands

Source: slash_commands.dart

A candidate produced by a command's argument completer.

Classes

SlashArgCandidate

A candidate produced by a command's argument completer.

Constructor

dart
const SlashArgCandidate({
    required this.value,
    this.description = '',
    this.continues = false,
  })

Properties

PropertyTypeDescription
valueString
descriptionString
continuesboolWhen true, SlashAutocomplete.accept() appends a trailing space so the user can keep typing further args. Use for subcommands that expect another token (e.g. /provider add → await ID).

abstract SlashCommand

Base type for a registered slash command.

Class-based commands (those owning their domain logic) extend this and override name, description, execute, and optionally aliases, hiddenAliases, argCompleter. Legacy inline registrations use [SlashCommand.inline] to construct an anonymous subclass.

Constructor

dart
SlashCommand()
dart
factory SlashCommand.inline({
    required String name,
    required String description,
    List<String> aliases,
    List<String> hiddenAliases,
    required String Function(List<String> args) execute,
    SlashArgCompleter? argCompleter,
  })

Convenience constructor for legacy registrations that don't yet have a dedicated class. Prefer subclassing for new commands.

Properties

PropertyTypeDescription
nameString get
descriptionString get
aliasesList&lt;String&gt; get
hiddenAliasesList&lt;String&gt; get
argCompleterSlashArgCompleter? getOptional argument autocomplete. Override to expose suggestions; default returns no completions.
nameString
descriptionString
aliasesList&lt;String&gt;
hiddenAliasesList&lt;String&gt;
argCompleterSlashArgCompleter?
commandsList&lt;SlashCommand&gt; getAll registered commands.
nameString get
descriptionString get
aliasesList&lt;String&gt; get
hiddenAliasesList&lt;String&gt; get
argCompleterSlashArgCompleter? getOptional argument autocomplete. Override to expose suggestions; default returns no completions.
commandsList&lt;SlashCommand&gt; getAll registered commands.

Methods

String execute(List&lt;String&gt; args)

Returns inline output. '' for async paths (the command later posts results via ctx.conversation.notify).

String execute(List&lt;String&gt; args)
void register(SlashCommand command)
void registerAll(Iterable&lt;SlashCommand&gt; commands)
String? execute(String input)

Parse and execute a slash command string. Returns the output text, or null if not found.

SlashCommand? findByName(String name)

Find a command by its primary name or any alias/hidden alias. Matching is case-insensitive.

SlashCommandRegistry

Registry of all slash commands.

Properties

PropertyTypeDescription
commandsList&lt;SlashCommand&gt; getAll registered commands.
commandsList&lt;SlashCommand&gt; getAll registered commands.

Methods

void register(SlashCommand command)
void registerAll(Iterable&lt;SlashCommand&gt; commands)
String? execute(String input)

Parse and execute a slash command string. Returns the output text, or null if not found.

SlashCommand? findByName(String name)

Find a command by its primary name or any alias/hidden alias. Matching is case-insensitive.

Released under the MIT License.