A complete Discord bot with Roblox verification, role binding, points system, and game integration.
- Roblox Verification - Link Discord accounts to Roblox profiles
- Role Binding - Automatically sync Discord roles with Roblox group ranks
- Points System - Track and reward members with points
- REST API - Allow Roblox games to give points and log activity
- CMDR Integration - Admin commands in Roblox games
- Activity Tracking - Automatically award points for in-game activities
Before you start, you'll need:
- Node.js (v18 or higher) - Download here
- PostgreSQL database - Download here
- Discord Bot Token - From Discord Developer Portal
- A server or computer to run the bot 24/7
- Go to https://discord.com/developers/applications
- Click "New Application" and give it a name
- Go to the "Bot" tab on the left
- Click "Add Bot" and confirm
- Under the bot's username, click "Reset Token" and copy it (you'll need this later)
- Scroll down and enable these Privileged Gateway Intents:
- โ Server Members Intent
- โ Message Content Intent (optional)
- Go to the "OAuth2" tab
- Copy your Application ID (also called Client ID)
- Download and install PostgreSQL from https://www.postgresql.org/download/windows/
- During installation, remember the password you set for the
postgresuser - Open pgAdmin 4 (installed with PostgreSQL)
- Right-click "Databases" โ "Create" โ "Database"
- Name it
roblox_botand click "Save"
# Install PostgreSQL using Homebrew
brew install postgresql@14
brew services start postgresql@14
# Create database
createdb roblox_bot# Install PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib
# Start PostgreSQL
sudo systemctl start postgresql
# Create database
sudo -u postgres createdb roblox_bot- Download or clone this repository to your computer
- Open Terminal (macOS/Linux) or Command Prompt (Windows)
- Navigate to the bot folder:
cd path/to/The-Soviet-Union-bot - Install dependencies:
npm install
-
Copy the example environment file:
# On Windows: copy .env.example .env # On macOS/Linux: cp .env.example .env
-
Open
.envin a text editor (like Notepad, VS Code, etc.) -
Fill in the values:
DISCORD_TOKEN=your_bot_token_here DISCORD_CLIENT_ID=your_application_id_here DATABASE_URL=postgresql://postgres:your_password@localhost:5432/roblox_bot PORT=3000 NODE_ENV=production
Explanation:
DISCORD_TOKEN: The bot token you copied from Discord Developer PortalDISCORD_CLIENT_ID: The Application ID from Discord Developer PortalDATABASE_URL: Connection string for your database- Replace
your_passwordwith your PostgreSQL password - If your database has a different name, replace
roblox_bot
- Replace
PORT: The port for the API server (default: 3000)
Run these commands one by one:
# Generate Prisma client
npm run prisma:generate
# Create database tables
npm run prisma:migrateIf it asks for a migration name, type something like init and press Enter.
npm run devnpm run build
npm startYou should see:
[INFO] Bot is ready! Logged in as YourBotName#1234
[INFO] API server is running on port 3000
๐ Your bot is now running!
- Go to https://discord.com/developers/applications
- Select your application
- Go to OAuth2 โ URL Generator
- Select these scopes:
- โ
bot - โ
applications.commands
- โ
- Select these bot permissions:
- โ Manage Roles
- โ Manage Nicknames
- โ Send Messages
- โ Manage Messages
- โ Embed Links
- โ Read Message History
- โ Add Reactions
- Copy the generated URL at the bottom
- Paste it in your browser and select your server
- Click "Authorize"
Run these commands in your Discord server:
/setprimarygroup [your_roblox_group_id]
/setlogchannel #logs
/setverifiedrole @Verified
/setunverifiedrole @Unverified
/setofficerrank 100
/setapikey
Explanation:
/setprimarygroup: Your main Roblox group ID (find it in the group URL)/setlogchannel: Channel where the bot logs activities/setverifiedrole: Role given to verified members/setunverifiedrole: Role given before verification/setofficerrank: Minimum Roblox rank to give/remove points/setapikey: Generates an API key for Roblox game integration
PM2 keeps your bot running 24/7 and restarts it if it crashes.
# Install PM2 globally
npm install -g pm2
# Build the bot first
npm run build
# Start the bot with PM2
pm2 start dist/index.js --name "roblox-bot"
# Make PM2 start on system boot
pm2 startup
pm2 saveUseful PM2 commands:
pm2 status # Check if bot is running
pm2 logs roblox-bot # View bot logs
pm2 restart roblox-bot # Restart the bot
pm2 stop roblox-bot # Stop the bot-
Make sure your bot is running and accessible from the internet
-
If running locally, you'll need to:
- Port forward port 3000 on your router
- Or use a service like ngrok: https://ngrok.com/
-
Get your API key by running
/setapikeyin Discord
See roblox/CMDR_SETUP.md for detailed instructions on:
- Installing CMDR in your Roblox game
- Adding the bot commands (givepoints, checkpoints, etc.)
- Configuring the API connection
/verify [username]- Start verification process/verify-check [username]- Complete verification/reverify [username]- Link a different account/whois [@user or roblox username]- Look up a user
/setprimarygroup [group id]- Set primary Roblox group/autobind- Auto-create and bind all group ranks/bind [role] [rank]- Manually bind a rank/unbind [role]- Remove a binding/binds- List all bindings/rangebind [group id] [min] [max] [role]- Bind rank range/update [@user]- Update someone's roles
/groupbind [group id] [role]- Bind group membership/groupunbind [group id]- Remove group binding/groupbinds- List group bindings
/points [@user]- Check points/givepoints [@user] [amount] [reason]- Give points/removepoints [@user] [amount] [reason]- Remove points/batch [amount] [reason] @user1 @user2...- Batch points/leaderboard- Top users by points/pointshistory [@user]- Point transactions/setpoints [@user] [amount]- Set exact points (admin)/resetpoints [@user]- Reset to 0 (admin)/setthreshold [points] [message]- Set point milestone
/config- View server configuration/setlogchannel [#channel]- Set log channel/setverifiedrole [@role]- Set verified role/setunverifiedrole [@role]- Set unverified role/setofficerrank [rank]- Set officer rank/setadminrole [@role]- Set admin role/setnickname [format]- Set nickname format/setapikey [key]- Set/generate API key/setactivitypoints [type] [points]- Configure activity points
/help- Show all commands/ping- Check bot latency
All endpoints require an API key in the request body or query parameter.
Give points to a user from Roblox game
{
"robloxId": 123456789,
"amount": 50,
"reason": "Attended training",
"givenBy": 987654321,
"apiKey": "your-api-key"
}Remove points from a user
{
"robloxId": 123456789,
"amount": 25,
"reason": "Penalty",
"removedBy": 987654321,
"apiKey": "your-api-key"
}Get user's points
Get full user information
Log activity (playtime, events, etc.)
{
"robloxId": 123456789,
"activityType": "playtime",
"value": 60,
"metadata": {},
"apiKey": "your-api-key"
}Check if user is verified
- Make sure the bot is online (green status)
- Check bot permissions in your server
- Try
/pingto see if bot responds - Check console for error messages
- Make sure PostgreSQL is running
- Check your DATABASE_URL in
.env - Verify database exists:
psql -l(should showroblox_bot)
- Wait a few minutes (Discord can take time to update)
- Try kicking and re-inviting the bot
- Make sure you used the correct invite link with
applications.commandsscope
- Make sure your server is accessible from the internet
- Check firewall settings (allow port 3000)
- Test by visiting
http://your-ip:3000/healthin browser - For local testing, use ngrok or similar
- Make sure bot's role is ABOVE the roles it needs to assign
- Check bot has "Manage Roles" permission
- Verify group ID and rank numbers are correct
- Open Windows Defender Firewall
- Click "Advanced settings"
- Click "Inbound Rules" โ "New Rule"
- Select "Port" โ "TCP" โ Specific port: 3000
- "Allow the connection" โ Name it "Discord Bot API"
- Log into your router (usually 192.168.1.1 or 192.168.0.1)
- Find "Port Forwarding" or "Virtual Server"
- Add new rule:
- External Port: 3000
- Internal Port: 3000
- Internal IP: Your computer's local IP
- Protocol: TCP
- Save and restart router
sudo ufw allow 3000/tcp
sudo ufw reloadIf you're stuck:
- Check the console/logs for error messages
- Make sure all prerequisites are installed correctly
- Verify all environment variables are set correctly
- Check that PostgreSQL is running
- Test the API health endpoint:
http://localhost:3000/health
The-Soviet-Union-bot/
โโโ src/
โ โโโ commands/ # Discord slash commands
โ โโโ events/ # Discord event handlers
โ โโโ api/ # Express API routes
โ โโโ lib/ # Utilities (Roblox API, logger, etc.)
โ โโโ db/ # Prisma client
โ โโโ index.ts # Main entry point
โโโ roblox/
โ โโโ cmdr-commands/ # Lua commands for CMDR
โ โโโ BotConfig.lua # Roblox configuration
โ โโโ CMDR_SETUP.md # CMDR integration guide
โโโ prisma/
โ โโโ schema.prisma # Database schema
โโโ .env # Environment variables
โโโ package.json # Dependencies
โโโ README.md # This file
- Never share your
.envfile or API key publicly - Use HTTPS in production (not HTTP)
- Restrict CMDR commands to trusted admins only
- Keep dependencies updated:
npm update - Use strong passwords for your database
MIT License - Feel free to modify and use for your own projects!