Skip to main content
The chapterjs command comes with the chapterjs package. Projects made with create chapterjs run it through their scripts (dev, build, start, test, postinstall).
How to use each command is in the guide: chapterjs dev, chapterjs build, chapterjs start, chapterjs test, Deploy. What every message means is in Troubleshooting.

Commands

Every command runs in the folder of the project: the one with package.json and src/. Without src/, dev, build and test stop with ✗ There is no src folder here.

chapterjs dev

Runs the bot of the current folder on the test server of DEV_GUILD_ID, and reloads every file under src/ when it is saved. Runs until stopped. Takes no option.

chapterjs build

Checks the project and compiles it into .chapterjs/build/. Needs no token and sends nothing to Discord. A build that fails leaves no .chapterjs/build/ behind. Takes no option.

chapterjs start

Runs the build for everyone. Runs until stopped.
integer
How many processes run the bot: a whole number of 1 or more, written --processes 4 or --processes=4. Capped at the number of shards, with an ℹ saying so. Anything else after start stops the command with ✗ chapterjs start takes one option: ....

chapterjs test

Checks the bot against a Discord in memory. Needs no token and sends nothing to Discord. Takes no option. Stores keep their data in memory: the data/ folder of the project is never touched.

chapterjs sync

Writes the .chapterjs/ folder of the project: what the project adds to the types of chapterjs (the files of public/, its languages and its commands, found by reading the files without running them) and the tsconfig.json of the one TypeScript project that covers src/. Prints ✓ Types written to .chapterjs/. Needs no token. dev and build do it too when they start; templates run it as postinstall. Only files whose content changed are written; what an older version wrote is removed. .chapterjs/cache/ and .chapterjs/build/ are left alone.

chapterjs --version

Prints the version of the package. -v works too.

chapterjs --help

Prints the usage above. -h and no command at all do the same. Any other word is an error: ✗ "…" is not a command., followed by the usage.

Environment

.env

dev and start read the .env file of the project folder, when there is one, then the real environment: a variable set in the environment wins over the file. Values are trimmed.
string
required
The token of the bot, from the Bot page of the application in the Developer Portal. A Bot prefix is removed. Refused when empty, when it is a placeholder left from an example (your-token-here, xxx, todo, changeme, <...>…) or when it contains a space.
string
The ID of the test server: 17 to 20 digits. Required by dev, which runs the bot in that server only. Optional for start, which then ignores that server, so that dev and start can share one token without answering the same thing twice. Refused when it is not an ID.
string
The address of the Redis that the stores declared with storage: 'redis' use: redis://host:port, rediss:// for a TLS connection, /1 at the end for a database other than the first, a user and a password before the host when there are some (redis://user:password@host:6379). Only needed when a store says storage: 'redis'; with it set and no such store, nothing is connected. Refused when it is not an address of that form. See Storage.
string
The password of that Redis, when it is not in REDIS_URL (or to replace the one that is). Refused when REDIS_URL is not set.
Without a .env file, dev stops with ✗ There is no .env file in this folder. when neither value is in the environment, and start with ✗ BOT_TOKEN is not set. when the token is not.

Other variables

string
Set to anything to print the symbols without color. Colors are only used when the output is a terminal anyway.
string
Read by Node itself. --max-old-space-size=<MB> raises the memory the bot may use: see Memory.
Whether a person is watching (dev waits for a fix instead of stopping) is decided by the terminal: both the input and the output must be a terminal.

Exit codes

Symbols

Every line printed by the CLI starts with one of five symbols. Lines that follow the first one of a message are indented under it. An error in a file of the project is prefixed with its path, and its line when known: ✗ src/commands/ping.ts:4 …. With several processes, every line of a process starts with its number: [2] ✓ ….

.chapterjs/

What the CLI keeps in the project, ignored by git: The folder can be deleted at any time: sync writes the types again, the next dev or start registers the commands again, and build makes a new build.