chapterjs start runs. On your computer it stops when you close the terminal, so a bot for everyone lives on a machine that stays on: a server you rent, a container, a host made for Node applications. Whatever it is, the steps are the same.
1
Put your project there
Clone your repository, or copy the folder without
node_modules and .chapterjs (both are made on the machine). The machine needs Node.js 24 or newer and a package manager.2
Install
Run the install command of your package manager in the folder. The install also writes the types of the project (Keep the development dependencies if you want the build to check the types there: without TypeScript,
postinstall runs chapterjs sync).chapterjs build says ℹ Types were not checked and goes on.3
Give it the token
Set
BOT_TOKEN the way the machine does it: an environment variable, the “secrets” of a host, or a .env file in the folder. It is the token of your production application, not the one of the .env on your computer: see A second bot for development. The real environment wins over the file. The token is the only value chapterjs start requires..env
4
Build
Run the
build script. It checks every file and compiles the bot into .chapterjs/build: see chapterjs build.5
Start
build and start scripts of your project. A host that takes your project from git does the first two steps by itself.
The environment variables and the exit codes of
chapterjs start are in the CLI reference.Environment variables
Nothing else is read. In particular, there is no option for the intents, the commands or what the bot remembers: all of it comes from your files.
Keeping it running
chapterjs start runs until it is stopped. Two things end it:
- A stop asked by the machine (
Ctrl+C, aSIGTERMfrom a host or a process manager): the bot disconnects cleanly, prints✓ Disconnectedand exits with code 0. Give it a few seconds for that before killing it: a bot killed at once stays shown online until Discord notices. - Something to fix: a refused token, a privileged intent not enabled, no build, too many sessions started today. The message says what, and the command exits with code 1.
chapterjs start, nothing needs your help: the connection is kept alive and reconnected when it drops, and a large bot’s processes are started again when one of them stops.
Updating the bot
Put the new files on the machine, build, start again. Until you build, the running bot keeps the previous build, andchapterjs start reminds you of it:
If you build on your computer and upload the result, upload
.chapterjs/build too (it is not in git), and use the same version of ChapterJS and of Node on both sides. The packages the bot uses stay in node_modules: production needs them installed.Large bots
A bot in thousands of servers runs on several processes by itself, one for every 4 shards and never more than the machine has CPUs. Pass--processes to choose:
Troubleshooting
Every message, and what to do about it.
CLI reference
Every command, variable and exit code.