Skip to main content

Dashboard Setup

The MJ Bot dashboard is a web application built with Next.js that provides a browser-based interface for managing your bot. It uses NextAuth for Discord OAuth2 authentication and Prisma for database access.

Prerequisites

Before setting up the dashboard, make sure you have completed the bot installation and have the following ready:

  • Node.js 18 or later
  • npm
  • pm2 (installed globally)
  • A running database (the same one used by the bot)

Installation

Navigate to the dashboard directory and install dependencies:

cd dashboard
npm install
tip

If you encounter permission errors, avoid using sudo npm install. Instead, fix your npm permissions or use a Node version manager like nvm.

Building the Dashboard

Next.js requires a production build before it can be started:

npm run build

This compiles the application and outputs optimized files for production. The build step must complete without errors before proceeding.

warning

If the build fails, check the terminal output carefully. Common causes include missing environment variables in your .env file or unresolved Prisma schema issues. Make sure you have run npx prisma generate before building.

Starting the Dashboard

Start the dashboard as a background process using pm2:

pm2 start "npm start" --name mj-dashboard

The dashboard runs on port 3000 by default. You can verify it is running with:

pm2 status

Check the logs if anything looks wrong:

pm2 logs mj-dashboard

Accessing the Dashboard

Once the dashboard is running, access it in your browser at:

http://your-server-ip:3000

Replace your-server-ip with the public IP address of your server.

info

If you are running the dashboard locally for development, you can access it at http://localhost:3000.

danger

Do not expose port 3000 directly to the internet in production. Set up a reverse proxy with nginx and SSL instead. See the Domain Setup guide for instructions.

Next Steps

  • Domain Setup -- Point a domain to your dashboard with nginx and SSL.
  • Authentication -- Configure Discord OAuth2 login for the dashboard.