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
const SlashArgCandidate({
required this.value,
this.description = '',
this.continues = false,
})Properties
| Property | Type | Description |
|---|---|---|
value | String | |
description | String | |
continues | bool | When 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
SlashCommand()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
| Property | Type | Description |
|---|---|---|
name | String get | |
description | String get | |
aliases | List<String> get | |
hiddenAliases | List<String> get | |
argCompleter | SlashArgCompleter? get | Optional argument autocomplete. Override to expose suggestions; default returns no completions. |
name | String | |
description | String | |
aliases | List<String> | |
hiddenAliases | List<String> | |
argCompleter | SlashArgCompleter? | |
commands | List<SlashCommand> get | All registered commands. |
name | String get | |
description | String get | |
aliases | List<String> get | |
hiddenAliases | List<String> get | |
argCompleter | SlashArgCompleter? get | Optional argument autocomplete. Override to expose suggestions; default returns no completions. |
commands | List<SlashCommand> get | All registered commands. |
Methods
String execute(List<String> args)
Returns inline output. '' for async paths (the command later posts results via ctx.conversation.notify).
String execute(List<String> args)
void register(SlashCommand command)
void registerAll(Iterable<SlashCommand> 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
| Property | Type | Description |
|---|---|---|
commands | List<SlashCommand> get | All registered commands. |
commands | List<SlashCommand> get | All registered commands. |
Methods
void register(SlashCommand command)
void registerAll(Iterable<SlashCommand> 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.