chapterjs dev needs two things from it: the token of the bot and the ID of the server you test in.
Create two applications from the start: one for development, one for production. Name them after your bot, with “dev” in the name of the first (
my-bot dev, my-bot). The token of the dev one goes in the .env of your computer, the token of the other one on the machine that will host your bot. A command for everyone belongs to the bot, not to a server, so with one bot for both your test server shows every command you are changing twice, and the presence, the privileged intents and the token of production are shared with what you try. Why in detail: A second bot for development.1
Create the application
Open the Developer Portal, click New Application and give it a name: it is the name people see. Do it twice, once for the dev bot and once for the production bot.Then open the Bot page of the application. This is where the bot account of your application lives: its username, its avatar and its token.
2
Copy the token
On the Bot page of the dev application, click Reset Token and copy the token it shows. Discord shows a token once: if you lose it, reset it again, which makes the old one stop working everywhere it was used.Put it in the
.env file of your project:.env
3
Copy the ID of your test server
Your test server is where
chapterjs dev runs your bot. Any server you manage works: create one for your bot if you don’t have one.Server IDs are hidden until you enable Developer Mode in Discord: Settings → Advanced → Developer Mode. Then right-click your server and choose Copy Server ID. The ID is a number of 17 to 20 digits. Put it in DEV_GUILD_ID.4
Add the bot to your test server
Nothing to find: run your bot, and Open the link, confirm, and the command goes on by itself:The link adds the bot to that server only, with every permission (
chapterjs dev prints the link when the bot is not in the server yet.permissions=8 is Administrator): a test server is a playground. It also asks for the applications.commands scope, which lets the bot have slash commands there.chapterjs dev and your bot is online in your test server. The rest of this page is about the three options of the Bot page that some files need.
Privileged intents
Discord only sends a bot what it asked for, and three things have to be enabled by hand, under Privileged Gateway Intents on the Bot page of your application: Presence Intent, Server Members Intent and Message Content Intent. You never list them in your code: ChapterJS works out what your files need, and asks you to enable an option only when a file needs it.
When a file needs an option that is not enabled,
chapterjs dev says which files and gives the link to the page, then waits:
chapterjs dev only waits when it runs in a terminal. Started by another program, and in production with chapterjs start, the same message is an error (✗) and the command stops.A bot in 100 servers or more has to be verified by Discord to keep its privileged intents. Until then, the options can be enabled freely on the Bot page.
When something is wrong with a value
Each value of.env is checked before anything is tried, and every problem is printed at once, with how to fix it:
Project structure
What each folder and file of your project is for.
chapterjs dev
Run your bot on your test server while you write it.