This guide walks you through setting up Doubt for local development.
Prerequisites
- Node.js v16.11 or higher (v18+ LTS recommended)
- npm (included with Node.js)
- MongoDB — either a local instance, Docker container, or MongoDB Atlas cluster
- Discord Application — create one at the Discord Developer Portal
Step 1: Clone the Repository
Step 2: Install Dependencies
This installs all runtime dependencies and the Prisma CLI (dev dependency). The Prisma client is auto-generated during install via the postinstall hook.
If you need to regenerate the Prisma client manually:
Copy the environment template:
Fill in the required values. See Configuration for details on each variable.
At minimum for development, you need:
Never commit .env or src/config.js to version control. Both files are gitignored and contain secrets.
Copy the configuration template:
Edit src/config.js to set:
moderation.developers — array of Discord user IDs who can use developer commands
moderation.staffRoles — array of role IDs for staff-only commands
variables.channels.logs — channel ID for logging (optional)
variables.channels.botGuilds / botUsers — channel IDs for stat displays (optional, but the bot will error every 30 minutes if not configured)
Step 5: Set Up the Discord Application
- Go to the Discord Developer Portal
- Create a new application (or use an existing one)
- Navigate to Bot → copy the bot token → paste as
DEV_TOKEN in .env
- Copy the Application ID → paste as
DEV_CLIENT_ID
- Enable these Privileged Gateway Intents:
- Presence Intent
- Server Members Intent
- Message Content Intent
- Navigate to OAuth2 → URL Generator:
- Scopes:
bot, applications.commands
- Permissions: Administrator (or the specific permissions you need)
- Use the generated URL to invite the bot to your test server
- Copy your test server ID → paste as
DEV_GUILD_ID
Step 6: Set Up MongoDB
Option A: Docker (recommended for development)
Set DEV_MONGODB_URI=mongodb://localhost:27017/doubt-dev in your .env.
Option B: MongoDB Atlas
- Create a free cluster at MongoDB Atlas
- Create a database user and get the connection string
- Set
DEV_MONGODB_URI to the Atlas connection string
Step 7: Run the Bot
Development mode (with auto-restart):
Production mode:
You should see:
- Command loading tables (slash, prefix, dev-only)
- Event registration table
- Component loading table
[SUCCESS] Prisma connected to MongoDB!
Logged in on discord as: YourBot#1234
Running on http://0.0.0.0:8080
Step 8: Verify
- Check the health endpoint:
curl http://localhost:8080/
- In your Discord test server, try
/ping or /test
- Run the test suite:
npm test
Common Issues
Bot doesn’t respond to slash commands
- Verify
DEV_GUILD_ID matches your test server ID
- Check that the bot has the
applications.commands scope
- Wait a few seconds after startup for command registration
MongoDB connection fails
- Ensure MongoDB is running and accessible at the URI you configured
- For Atlas: check that your IP is whitelisted in Network Access
- Verify the connection string format includes the database name
Channel editing errors every 30 minutes
The bot tries to rename botGuilds and botUsers channels periodically. If these channel IDs are empty or invalid in config.js, the bot will log errors. Either set valid channel IDs or ignore these non-fatal errors.
Prefix commands don’t work
Prefix commands are disabled by default. In src/config.js, set handler.commands.prefix to true to enable them.