Skip to main content
Three tools are enough to write a bot: Node.js to run your code, a package manager to install ChapterJS, and an editor. This page makes sure you have them, and shows the few terminal commands the rest of the tutorial uses.

The terminal

Everything that runs your bot is started from a terminal: a window where you type a command and read what it answers. On macOS it is the Terminal app; on Windows, Windows Terminal or PowerShell; on Linux, whatever your system calls it. Your editor also has one built in, which is the most convenient place for it. Two things to know:
  • A terminal is always “in” a folder. cd my-bot moves into the folder my-bot; the commands of this tutorial are run from the folder of your project.
  • A program that keeps running (like your bot) keeps the terminal busy. Ctrl+C stops it.

Node.js

Node.js is what runs JavaScript outside of a browser. ChapterJS needs version 24 or newer: it relies on Node running TypeScript files directly, and it follows the recent versions of Node. With an older one, ChapterJS stops at once and says what to install. Install it from nodejs.org (the LTS version is fine when it is 24 or newer), then check in a terminal:
It prints something like v24.11.1. If it prints a lower version, or “command not found”, install it again and open a new terminal: a terminal opened before the install does not see it.

A package manager

A package manager downloads the packages your project depends on (here, chapterjs) and runs the scripts of your project (dev, build, start). Node comes with npm. The others, pnpm, yarn and bun, do the same thing with small differences in speed and in how they store packages. Pick one; pnpm is the one the ChapterJS team uses. Check the one you chose:
If pnpm is not installed, corepack enable pnpm turns it on, since it ships with Node; or follow pnpm.io.
Stick to one package manager per project. Each one keeps its own lock file (pnpm-lock.yaml, package-lock.json…), and using two in turn leaves them disagreeing, with errors that are hard to understand.

An editor

Any editor that understands TypeScript works, and Visual Studio Code does out of the box. The editor matters more than usual with ChapterJS: the framework generates the types of your project, and the editor reads them to complete what you type and to underline a mistake before you run anything. That is where a lot of the help comes from, so take the time to open your project in it rather than in a plain text editor.

A Discord account and a server to test in

You need a Discord account and a server where you have the right to add a bot (any server you created works). Make one for your bot if you don’t have one: a test server is a playground where mistakes bother nobody. In Discord, click the + at the bottom of the server list and choose Create My Own.

Recap

  • node --version says 24 or newer.
  • One package manager, checked with --version, and kept for the whole project.
  • An editor that understands TypeScript, Visual Studio Code for example.
  • A Discord account and a test server you manage.

Your Discord application

Create the bot account in the Developer Portal.

Creating the project

One command, two values, and your bot is online.