Skip to main content

Dotenv Setup


Environment Setup Guide

This guide explains how to set up the .env file for PG.


Step 1: Create a .env file

In the root of your project, create a file named .env:

touch .env

Step 2: Add Environment Variables

Copy and paste the following into your .env file, then update with your own values:

# -----------------------------
# Database (MongoDB)
# -----------------------------
MONGO_URI=mongodb://localhost:27017/pg-bot
# For MongoDB Atlas (example):
# MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/pg-bot

# -----------------------------
# Discord Bot
# -----------------------------
BOT_TOKEN=your_discord_bot_token_here
CLIENT_ID=your_discord_client_id
CLIENT_SECRET=your_discord_client_secret


For Dashboard


# -----------------------------
# Dashboard
# -----------------------------
DASHBOARD_URL=http://localhost:3000
API_URL=http://localhost:3000/api

# -----------------------------
# Server
# -----------------------------
PORT=3000

# -----------------------------
# Security
# -----------------------------
ENCRYPTION_KEY=your_32_character_secret_key


Step 3: Where to Get These Values

MONGO_URI → From your local MongoDB instance or MongoDB Atlas

BOT_TOKEN, CLIENT_ID, CLIENT_SECRET → From Discord Developer Portal

ENCRYPTION_KEY → Generate a random 32-character string (you can use openssl rand -base64 24)

YouTube/Spotify keys → Only needed if you plan to use those music features


Step 4: Verify

Run the app in development mode:

npm run dev

If your .env is set up correctly, the bot + dashboard should start without errors.