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:
- npm
- pnpm
- yarn
$ npx forgeloop add command status --description "Show bot status"
$ pnpm forgeloop add command status --description "Show bot status"
$ yarn 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:
- npm
- pnpm
- yarn
$ npx forgeloop add context-menu inspect-user --type user
$ pnpm forgeloop add context-menu inspect-user --type user
$ yarn 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-subcommandsadds a nesteddemogroup and example subcommand.--autocompleteadds anautocomplete(...)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:
npx forgeloop add command
After adding
- Development: restart the bot or rely on your workflow so
syncCommandsruns again, or usecommands deploy. - Command name rules: letters, numbers, hyphens, underscores — normalized to lowercase.
- Context menu target: use
--type useror--type message.
Full flags and edge cases: forgeloop add.