Discord Bot
Scaffold a Discord bot with discord.js, TypeScript, and explicit development and production entry points.
Why Use This Command?
- Separates Discord client construction from login so Vitest can exercise the starter without connecting to Discord.
- Keeps the bot token in an untracked
.envfile while documenting the required key in the tracked.env.sample. - Uses a fixed-width Nova header and clear connection states while keeping the bot token out of terminal output.
- Uses Nova's type-check and transpile utilities so checking and production output follow the same contract as other workspaces.
- Can contribute the background service to the repository-wide s6 Docker appliance without adding an HTTP port.
Requirements
- Node.js runtime — Use any Node.js LTS release.
- Discord application token — Create a bot in the Discord Developer Portal, add it to a server with the
botscope, and provide its token asDISCORD_TOKENafter scaffolding. - Empty directory or monorepo root — Nova auto-detects whether to create a project or add a workspace.
Usage
Options
| Flag | Description |
|---|---|
-d, --dry-run | Run without writing any files. |
--docker-image | Add the bot as a supervised service in the repository-wide s6 image. |
--install | Install dependencies after scaffolding; this is the default. |
--no-install | Skip dependency installation. |
--name <name> | Project slug when creating a new monorepo; omit at an existing root. |
--non-interactive | Require every answer as a flag and do not open prompts. |
--workspace-name <name> | Workspace directory name. |
--output <dir> | Output directory. |
Output Files
| File | Description |
|---|---|
.env | Untracked Nova defaults and the blank DISCORD_TOKEN value. |
.env.sample | Shareable Nova defaults and the required DISCORD_TOKEN key. |
src/bot.ts | Import-safe client factory, login flow, and status output. |
src/bot.test.ts | Offline Vitest coverage for intents, status, and validation. |
src/index.ts | Runtime token lookup and bot startup. |
tsconfig.*.json | Nova strict Node.js configs for source, tooling, and tests. |
package.json | discord.js dependencies and Nova-managed workspace scripts. |
With --docker-image, Nova adds root .dockerignore, Dockerfile, and compose.yml entry points plus private assembly files under packages/docker. The bot runs as a supervised longrun inside the repository's one s6 image.
See Docker Images for the shared runtime and layout contract.
First Run
- Create a Discord application and bot in the Discord Developer Portal.
- Open the application's Installation page and add the bot to your server with the
botscope. Installing only the application-command integration does not add a visible bot member. - Set
DISCORD_TOKENin the generated.env, then run the workspacedevcommand shown by Nova.
Nova doesn't request or store the token during scaffolding, and the token should not be passed as a command-line flag.
The root .gitignore generated by every Nova scaffold excludes .env files while keeping .env.sample tracked.
When the token is missing, the generated bot prints these setup steps instead of a stack trace.
Non-Interactive Mode
nova scaffold app discord-bot --non-interactive --name my-bot --workspace-name bot --output ./my-bot
nova scaffold app discord-bot --non-interactive --workspace-name bot --output ./apps/bot
nova scaffold app discord-bot --docker-image --non-interactive --name my-bot --workspace-name bot --output ./my-bot
Registration
Nova registers the workspace with the app role and trackable policy. Its package name follows {projectSlug}-app-{workspaceName}.
Nova also registers a same-named file artifact containing the runtime package.json and compiled build/ tree. Docker publishing remains a separate repository-wide OCI artifact.