Skip to main content

Sync application commands to Discord

Automatic sync (modular / advanced)

Generated modular and advanced bots call syncCommands during startup (see src/sync-commands.*). Behavior:

NODE_ENVTargetRequired env
productionGlobal application commandsDISCORD_TOKEN, CLIENT_ID
Anything else (e.g. development)Guild application commandsDISCORD_TOKEN, CLIENT_ID, GUILD_ID

Logs indicate whether commands were synced globally or to a guild.

Manual deploy: forgeloop commands deploy

Use this when you want to push definitions from src/commands without running the bot, or from CI.

npx forgeloop commands deploy

Rules:

  • --guild — always sync to the guild in GUILD_ID.
  • --global — always sync globally.
  • Without target flags — same as startup defaults: production -> global, non-production -> guild.

Requirements:

  • Modular or advanced project (command modules on disk).
  • Env: DISCORD_TOKEN, CLIENT_ID, and GUILD_ID whenever the target is guild (including default dev behavior).
  • TypeScript projects: deploy runs Node with tsx to import .ts command files — ensure dev dependencies are installed.

Timeout: 20 seconds per Discord API request; failures include Discord’s error message when JSON is returned.

Related command reference: forgeloop commands.