Deployment Guide
This page covers every way to run Meww.me: development, production, sharding, PM2, and Docker.
Prerequisites
| Requirement | Minimum Version | Notes |
|---|---|---|
| Node.js | 16.x+ | v18 or v20 LTS recommended |
| npm | 8.x+ | Comes with Node.js |
| Java | 17+ | Required for Lavalink server |
| Lavalink | v4 | Music audio server |
| Database | Any supported | MongoDB, 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 mewwmeStep 2 - Install Backend Dependencies
cd backend
npm installStep 3 - Install Frontend Dependencies
cd frontend
npm install
cd ..Step 4 - Configure the Bot
cp config.example.yml config.ymlEdit 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=developmentGenerate a secure session secret:
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"Step 6 - Build the Project
npm run buildThis compiles TypeScript from src/ to dist/ and copies language/data files.
For a full build (format + compile + data copy):
npm run build:fullStep 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.ymlThis file is a starting point and can be reconfigured to suit your needs (ports, passwords, plugins, source settings, etc.).
java -jar Lavalink.jarEnsure the host, port, and auth values in your bot's config.yml match your Lavalink application.yml.
Running Options
Development Mode
npm run devUses nodemon + tsx for hot reload. Restarts automatically on file changes.
Production - Build and Start
npm run start:prodThis runs build → build:data → start in sequence.
Or manually:
npm run build
npm run build:data
npm startProduction - With Sharding
npm run start:shardsStarts the cluster manager (dist/shard/index.js) which spawns worker processes based on SHARDING_SYSTEM config:
bot:
SHARDING_SYSTEM:
shardsPerClusters: 1
totalClusters: 1For 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 productionPM2 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 PM2Production - 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 \
mewwmeThe Dockerfile uses a multi-stage build:
- Base image:
node:22-alpine - Install dependencies
- Build TypeScript
- Copy data files
- Start with
node dist/index.js
Frontend Production
cd frontend
npm run buildThe 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
- Go to the Discord Developer Portal (opens in a new tab).
- Click "New Application" → enter a name → click "Create".
- Go to the "Bot" tab.
- Click "Add Bot" → confirm.
- Click "Reset Token" → copy the token immediately.
Enabling Privileged Intents
In the "Bot" tab:
- Scroll to "Privileged Gateway Intents".
- Enable all three:
- Presence Intent - presence/activity tracking
- Server Members Intent - member events and statistics
- Message Content Intent - prefix commands
- Click "Save Changes".
Generating an Invite URL
- Go to "OAuth2" → "URL Generator".
- Under "Scopes", select:
bot,applications.commands. - Under "Bot Permissions", select
Administrator(recommended) or individual permissions. - Copy the generated URL and open it in your browser.
Registering OAuth2 Redirect URI
- Go to "OAuth2" → "General".
- Under "Redirects", add your callback URL:
- Development:
http://localhost:2555/auth/discord/callback - Production:
https://api.yourdomain.com/auth/discord/callback
- Development:
Database Setup
Configure your database driver in config.yml. Supported drivers: mongodb, mysql, postgres, json.
Recommendation: Use
jsonfor development. For production, usepostgres(recommended) ormysql.
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.sqlOptional - 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:password@cluster.mongodb.net/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
| Script | Command | Description |
|---|---|---|
dev | nodemon --exec tsx src/index.ts | Development mode with hot reload |
start | node dist/index.js | Start from compiled output |
start:prod | build + build:data + start | Full production start |
start:shards | node dist/shard/index.js | Start with cluster manager |
build | tsc | Compile TypeScript |
build:data | node scripts/copyData.js | Copy language/data files to dist |
build:full | prettier + build + build:data | Full build with formatting |