Deployment Guide

Deployment Guide

This page covers every way to run Meww.me: development, production, sharding, PM2, and Docker.

Prerequisites

RequirementMinimum VersionNotes
Node.js16.x+v18 or v20 LTS recommended
npm8.x+Comes with Node.js
Java17+Required for Lavalink server
Lavalinkv4Music audio server
DatabaseAny supportedMongoDB, MySQL, PostgreSQL, or JSON

Step 1 - Prepare the Project

Extract the source code you received to a directory of your choice, then navigate into it:

cd mewwme

Step 2 - Install Backend Dependencies

cd backend
npm install

Step 3 - Install Frontend Dependencies

cd frontend
npm install
cd ..

Step 4 - Configure the Bot

cp config.example.yml config.yml

Edit config.yml with your settings. See Configuration for details.

Step 5 - Create .env File

TOKEN=your_discord_bot_token_here
SESSION_SECRET=random_64_char_hex_string
DISCORD_CLIENT_ID=your_client_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_REDIRECT_URI=http://localhost:2555/auth/discord/callback
FRONTEND_URL=http://localhost:3000
NODE_ENV=development

Generate a secure session secret:

node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"

Step 6 - Build the Project

npm run build

This compiles TypeScript from src/ to dist/ and copies language/data files.

For a full build (format + compile + data copy):

npm run build:full

Step 7 - Start Lavalink

Download Lavalink from GitHub Releases (opens in a new tab).

A reference application.yml is provided at backend/additional-file/application.yml. Copy it to the same directory as your Lavalink.jar:

cp additional-file/application.yml /path/to/lavalink/application.yml

This file is a starting point and can be reconfigured to suit your needs (ports, passwords, plugins, source settings, etc.).

java -jar Lavalink.jar

Ensure the host, port, and auth values in your bot's config.yml match your Lavalink application.yml.


Running Options

Development Mode

npm run dev

Uses nodemon + tsx for hot reload. Restarts automatically on file changes.

Production - Build and Start

npm run start:prod

This runs build → build:data → start in sequence.

Or manually:

npm run build
npm run build:data
npm start

Production - With Sharding

npm run start:shards

Starts the cluster manager (dist/shard/index.js) which spawns worker processes based on SHARDING_SYSTEM config:

bot:
  SHARDING_SYSTEM:
    shardsPerClusters: 1
    totalClusters: 1

For bots in over 2,500 guilds, increase the shard/cluster count.

Production - With PM2

npm install -g pm2
npm run build:full
pm2 start scripts/ecosystem.config.js --env production

PM2 provides:

  • Automatic restart on crash
  • Log management
  • Process monitoring
  • Cluster mode

The ecosystem.config.js defines:

module.exports = {
  apps: [{
    name: "mewwme",
    script: "dist/index.js",
    env_production: { NODE_ENV: "production" },
    env_development: { NODE_ENV: "development" },
  }],
};

Useful PM2 commands:

pm2 status              # Check process status
pm2 logs mewwme         # View logs
pm2 restart mewwme      # Restart
pm2 stop mewwme         # Stop
pm2 delete mewwme       # Remove from PM2

Production - With Docker

docker build -t mewwme .
docker run -d --name mewwme \
  -e TOKEN=your_token \
  -e NODE_ENV=production \
  -p 2555:2555 \
  -p 2444:2444 \
  mewwme

The Dockerfile uses a multi-stage build:

  1. Base image: node:22-alpine
  2. Install dependencies
  3. Build TypeScript
  4. Copy data files
  5. Start with node dist/index.js

Frontend Production

cd frontend
npm run build

The build output is in frontend/dist/. Serve with any static file server, reverse proxy, or deploy to Vercel/Netlify/Cloudflare Pages.


Discord Application Setup

Creating the Application

  1. Go to the Discord Developer Portal (opens in a new tab).
  2. Click "New Application" → enter a name → click "Create".
  3. Go to the "Bot" tab.
  4. Click "Add Bot" → confirm.
  5. Click "Reset Token" → copy the token immediately.

Enabling Privileged Intents

In the "Bot" tab:

  1. Scroll to "Privileged Gateway Intents".
  2. Enable all three:
    • Presence Intent - presence/activity tracking
    • Server Members Intent - member events and statistics
    • Message Content Intent - prefix commands
  3. Click "Save Changes".

Generating an Invite URL

  1. Go to "OAuth2" → "URL Generator".
  2. Under "Scopes", select: bot, applications.commands.
  3. Under "Bot Permissions", select Administrator (recommended) or individual permissions.
  4. Copy the generated URL and open it in your browser.

Registering OAuth2 Redirect URI

  1. Go to "OAuth2" → "General".
  2. Under "Redirects", add your callback URL:
    • Development: http://localhost:2555/auth/discord/callback
    • Production: https://api.yourdomain.com/auth/discord/callback

Database Setup

Configure your database driver in config.yml. Supported drivers: mongodb, mysql, postgres, json.

Recommendation: Use json for development. For production, use postgres (recommended) or mysql.

PostgreSQL (Recommended for Production)

Create the database and user:

CREATE DATABASE mewwme;
CREATE USER mewwme WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE mewwme TO mewwme;
features:
  DATABASE:
    driver: "postgres" # Note: mongodb, mysql, json, postgres
    config:
      host: "localhost"
      user: "mewwme"
      password: "your_password"
      database: "mewwme"

MySQL

Create the database and user:

CREATE DATABASE mewwme;
CREATE USER 'mewwme'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON mewwme.* TO 'mewwme'@'localhost';
FLUSH PRIVILEGES;
features:
  DATABASE:
    driver: "mysql" # Note: mongodb, mysql, json, postgres
    config:
      host: "localhost"
      port: 3306
      user: "mewwme"
      password: "your_password"
      database: "mewwme"

Optional - import schema:

mysql -u mewwme -p mewwme < docker/s31_mewwme.sql

Optional - enable automated backups:

features:
  DATABASE:
    MYSQLBACKUP:
      Enable: true
      Schedule: "0 0 * * *"
      Timezone: "Asia/Jakarta"
      ChannelId: "channel_id_here"

MongoDB

features:
  DATABASE:
    driver: "mongodb" # Note: mongodb, mysql, json, postgres
    config:
      uri: "mongodb://127.0.0.1:27017/mewwme"

For MongoDB Atlas:

features:
  DATABASE:
    driver: "mongodb"
    config:
      uri: "mongodb+srv://username:[email protected]/mewwme?retryWrites=true&w=majority"

JSON (Development Only)

No setup required. The bot creates the file automatically.

features:
  DATABASE:
    driver: "json" # mongodb, mysql, json, postgres
    config: { path: "./mewwme.database.json" }

Note: JSON driver is intended for development and testing only. For production, use PostgreSQL, MySQL, or MongoDB for reliability and performance.


npm Scripts Reference

ScriptCommandDescription
devnodemon --exec tsx src/index.tsDevelopment mode with hot reload
startnode dist/index.jsStart from compiled output
start:prodbuild + build:data + startFull production start
start:shardsnode dist/shard/index.jsStart with cluster manager
buildtscCompile TypeScript
build:datanode scripts/copyData.jsCopy language/data files to dist
build:fullprettier + build + build:dataFull build with formatting