Overview
Command types define the structure for both prefix commands and slash commands in Flora.Command
Type for prefix (text-based) commands.Properties
The command name (without prefix). Users type
<prefix><name> to invoke.Optional human-readable description of what the command does
Handler function that executes when the command is invokedParameters:
ctx: MessageContext- The message contextctx.args: string[]- Array of space-separated arguments after the command
Example
SlashCommand
Type for Discord slash commands.Properties
Command name (lowercase, no spaces, 1-32 characters)
Description shown in Discord’s UI (1-100 characters)
Array of command parameters. Mutually exclusive with
subcommands.Array of subcommands. Mutually exclusive with
options and run.Handler function for the command. Not used if
subcommands is provided.Example: Simple Command
Example: Command with Options
Example: Command with Subcommands
SlashCommandOption
Defines a parameter for a slash command.Properties
Option name (lowercase, no spaces, 1-32 characters)
Description shown in Discord’s UI (1-100 characters)
The value type this option acceptsAvailable types:
'string'- Text input (default)'integer'- Whole number'number'- Decimal number'boolean'- True/false'subcommand'- Nested subcommand'subcommand_group'- Group of subcommands
Whether this option must be provided
Nested options (for subcommands and subcommand groups)
Example
SlashSubcommand
Defines a subcommand within a slash command.Properties
Subcommand name (lowercase, no spaces)
Description shown in Discord’s UI
Parameters for this subcommand
Handler function for this subcommand
Example
FlattenedSlashCommand
Internal representation of a slash command for Discord registration.createBot() when registering commands with Discord. You typically don’t need to use this directly.
CreateOptions
Configuration object forcreateBot().
Properties
The prefix for text commands
Array of prefix commands (alias for
prefixCommands)Array of prefix commands
Array of slash commands to register
Example
Notes
- Command names must be lowercase with no spaces
- Slash command descriptions are required; prefix command descriptions are optional
- You cannot mix
subcommandswithoptions/runin the same slash command - Options in
ctx.optionsare automatically flattened and type-cast - Required options must come before optional options in the array