Skip to main content

Add a command

When this works

Only modular and advanced projects have src/commands. The basic preset keeps commands inline in src/index.*forgeloop add command will error with:

This ForgeLoop project uses the "basic" shape, so commands and events stay inline in index.ts/js. Switch to "modular" or "advanced" to use handler generators.

Add a slash command by name

From the project root:

$ npx forgeloop add command status --description "Show bot status"

The generator writes src/commands/status.ts (or .js) with a SlashCommandBuilder named status and a stub execute implementation.

Add a context menu command

Context menus live beside slash commands in the same folder:

$ npx forgeloop add context-menu inspect-user --type user

This writes src/commands/inspect-user.ts (or .js) with a ContextMenuCommandBuilder.

Higher-level command stubs

For slash commands, you can ask ForgeLoop to scaffold richer starter shapes:

  • --with-subcommands adds a nested demo group and example subcommand.
  • --autocomplete adds an autocomplete(...) export and option wiring.
  • Use both together when you want a ready-to-edit nested autocomplete example.

Interactive mode

With a TTY and no name on the command line, the CLI prompts for the command shape and relevant fields:

Interactive flow (illustrative)
bash
npx forgeloop add command
ForgeLoop • discord bot forgeCommand generatorShape a command with a clean prompt flow instead of raw file creation.? Command name> status? Description (default: …)> Show bot statusCommand summary│ Name: status│ Description: Show bot status✓ Added command "status" to …/src/commands/status.ts

After adding

  • Development: restart the bot or rely on your workflow so syncCommands runs again, or use commands deploy.
  • Command name rules: letters, numbers, hyphens, underscores — normalized to lowercase.
  • Context menu target: use --type user or --type message.

Full flags and edge cases: forgeloop add.