Running the Bot
With everything installed and configured, you are ready to start MJ Bot and the dashboard.
Start the Bot
From the project root, start the bot using pm2:
pm2 start bot/dist/index.js --name mj-bot
Check that it is running:
pm2 status
View the live logs:
pm2 logs mj-bot
You should see the bot log in and print a message like Logged in as MJ Bot#1234.
Start the Dashboard
cd dashboard
pm2 start npm --name mj-dashboard -- start
The dashboard will start on port 3000 by default. If you are using a reverse proxy (such as Nginx), point it to http://localhost:3000.
Invite the Bot to Your Server
- Open the invite URL you generated in the Bot Token step.
- Select the server you want to add the bot to.
- Confirm the permissions and authorize.
The bot should appear in your server's member list and respond to commands.
First-Time Setup
Once the bot is in your server, run these commands to get started:
| Command | Description |
|---|---|
/setup | Run the interactive setup wizard for your server |
/config prefix <prefix> | Change the command prefix for your server |
/config logs <channel> | Set the moderation log channel |
/config welcome <channel> | Set the welcome message channel |
/help | View all available commands |
Use the web dashboard for a more convenient way to configure all server settings. Log in at your dashboard URL with your Discord account.
pm2 Process Management
Here are the essential pm2 commands for managing MJ Bot:
Common Commands
# View all running processes
pm2 status
# Restart the bot
pm2 restart mj-bot
# Stop the bot
pm2 stop mj-bot
# View live logs
pm2 logs mj-bot
# View last 100 lines of logs
pm2 logs mj-bot --lines 100
Persistence Across Reboots
To ensure the bot starts automatically after a server reboot:
pm2 save
pm2 startup
The pm2 startup command will print a command you need to run with sudo. Copy and execute it.
Restarting After Code Changes
When you pull updates or make changes:
cd bot
npm run build
pm2 restart mj-bot
For the dashboard:
cd dashboard
npm run build
pm2 restart mj-dashboard
Monitoring
pm2 includes a built-in monitor:
pm2 monit
This shows real-time CPU, memory usage, and logs for all managed processes.
All Running Processes
After completing the full setup, your pm2 process list should look like this:
pm2 status
┌──────────────┬────┬──────┬───────┐
│ Name │ id │ mode │ status│
├──────────────┼────┼──────┼───────┤
│ mj-bot │ 0 │ fork │ online│
│ mj-dashboard │ 1 │ fork │ online│
│ lavalink │ 2 │ fork │ online│
└──────────────┴────┴──────┴───────┘
Never run the bot with node dist/index.js directly in production. Always use pm2 to ensure the process restarts automatically on crashes and persists across server reboots.