This guide walks you through getting the complete Capinetta RP Bot System running from scratch: both bots online, all slash commands registered in your Discord server, and the MariaDB database fully initialized through Prisma. By the end you’ll haveDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Capinetta-RP/capinetta-discord-bot/llms.txt
Use this file to discover all available pages before exploring further.
capinetta-general and capinetta-whitelist running as managed PM2 processes and ready to accept the initial /setup wizard.
Prerequisites
Before you begin, make sure the following are available on your host machine:- Node.js v18+ — v20 LTS is recommended. Check with
node --version. - MariaDB or MySQL 8.0+ — running locally or reachable via a connection string.
- Two Discord bot tokens — one for Bot General and one for Bot Whitelist. Create both at the Discord Developer Portal.
- PM2 installed globally — used to run both bots as persistent background processes:
Installation
Configure Environment Variables
Copy the example environment file and open it in your editor:Fill in at minimum the following required variables (see Configuration for the full reference):
All eight of these variables are validated at startup by
config.js. If any are missing, the bot will log a fatal error listing the absent keys and exit immediately — it cannot start without them.Install Dependencies and Initialize the Database
Install all Node.js packages, generate the Prisma client, and push the schema to your database:
If
npx prisma db push throws a connection error, your MariaDB service may not be running. Start it with:Deploy Slash Commands to Discord
Register the slash commands for both bots. This sends command definitions to the Discord API for your configured guild:Both scripts print Commands can take up to a few seconds to propagate in Discord. If you type
✅ Comandos registrados exitosamente on success. You can also run both at once:/ in your server and don’t see them immediately, wait a moment and retry.Start in Production with PM2
Launch both bots as persistent PM2 processes using the included PM2 will start two processes — To check running processes at any time:
ecosystem.config.js:capinetta-general (runs index-general.js) and capinetta-whitelist (runs index-whitelist.js) — both with NODE_ENV=production. Watch for these confirmation lines in the output:Run Initial Setup in Discord
With both bots online, run the interactive setup wizard inside any channel in your Discord server:The wizard guides you through:
- Setting the welcome channel (where Canvas welcome cards are posted on member join)
- Configuring the isolation zone (the restricted channel spam offenders are moved to)
- Defining the verified role given to members who pass the verification button check
/config.Troubleshooting
Cannot find module 'discord.js'
Cannot find module 'discord.js'
Dependencies were not installed or the installation was interrupted. Run:If the error persists, delete the
node_modules folder and try again:Connection refused (MariaDB / ECONNREFUSED)
Connection refused (MariaDB / ECONNREFUSED)
The MariaDB service is not running, or the credentials in Then confirm you can connect manually:If the service is running but the connection still fails, double-check the host, port, username, and password in your
DATABASE_URL are incorrect. First verify the service is active:DATABASE_URL.Invalid token / TokenInvalid error
Invalid token / TokenInvalid error
The bot token in
.env is incorrect, has extra whitespace, or has been regenerated since you last copied it.- Open the Discord Developer Portal and navigate to your application’s Bot tab.
- Click Reset Token, confirm, and copy the new token.
- Paste it into
.envasGENERAL_TOKENorWHITELIST_TOKEN— ensure there are no leading or trailing spaces. - Restart the bot:
pm2 restart all(ornpm startfor development).
Database does not exist
Database does not exist
Prisma cannot push the schema because the target database hasn’t been created yet. Create it manually in the MariaDB shell, then rerun the push:Make sure
DB_NAME in your DATABASE_URL matches the database name you just created.Bot is online but doesn't respond to slash commands
Bot is online but doesn't respond to slash commands
The slash commands were not deployed, or they were deployed to a different guild ID. Redeploy and ensure Also verify that the bot has the
GENERAL_GUILD_ID in .env matches your server’s ID:applications.commands OAuth2 scope and Administrator (or at minimum Send Messages + Use Slash Commands) permissions in your server. You can reinvite it with: