Lantern Discord Bot - Complete Guide โ
Standalone Discord bot for submitting feature requests and bug reports directly from Discord.
Status: โ
Production Ready
Location: discord-bot/
Source: bot.js, register-commands.js
Table of Contents โ
- Overview
- Features
- Architecture
- Environments
- Setup Instructions
- Local Testing
- Deployment
- Usage
- GitHub Integration
- Troubleshooting
- Monitoring & Maintenance
Overview โ
The Discord bot enables team members and users to submit feature requests and bug reports using Discord slash commands. All submissions automatically:
- Create GitHub issues with proper labels
- Post to public Discord channels (#features or #bugs)
- Notify admin team in private channel
- Store data in Firestore for tracking
- Integrate with GitHub Projects V2
Core Commands:
/feature- Submit a feature request/bug- Report a bug/mystatus- Check status of your submissions
Auto-Features:
- Smart auto-prompts for regular messages
- Multi-environment support (local, staging, production)
- Rate limiting to prevent spam
- Full audit trail in Firestore
Features โ
Smart Auto-Prompts โ
When users post a regular message in #features or #bugs (without using slash commands), the bot automatically:
- Detects the message in submission channels
- Replies with a helpful prompt explaining how to use the slash command
- Shows benefits of using structured forms
- Provides "Got it!" button to dismiss
- Auto-deletes after 30 seconds to keep channels clean
Example:
User: "The app crashes when I click the profile button"
Bot: ๐ก Quick Tip: Use /bug to submit
Hey @user! To submit a bug report, use the /bug slash command.
Why use slash commands?
โ
Structured form with all required details
โ
Automatic GitHub issue creation
โ
Tracked in our system
โ
You can check status with /mystatus
[Got it! button]Command Discovery โ
Users discover commands by:
- Typing
/in Discord (autocomplete shows available commands) - Reading pinned messages in #features and #bugs
- Checking channel topic descriptions
Architecture โ
Discord User
โ
/feature or /bug command
โ
Modal Form (Discord native)
โ
Bot validates input
โ
Creates GitHub issue + Firestore record
โ
Posts to #features or #bugs
โ
Notifies #admin-monitor
โ
User receives confirmation with GitHub linkKey Components:
bot.js- Main bot logic and command handlersregister-commands.js- Slash command registration- Discord.js - Bot framework
- Firebase Admin SDK - Firestore integration
- Octokit - GitHub API integration
Environments โ
| Environment | Purpose | Guild ID | Database | Location | Config |
|---|---|---|---|---|---|
| Local Testing | Dev & feature testing | Test guild (separate) | Dev database | Your machine | .env.testing |
| Dev Deployed | Staging/QA | Dev guild | Dev database | Railway | Railway vars |
| Production | Live users | Prod guild | Prod database | Railway | Railway vars |
Important: Each environment uses a separate Discord bot application and Firestore database.
Setup Instructions โ
Step 1: Create Discord Application โ
- Go to Discord Developer Portal
- Click "New Application"
- Name it "Lantern Bot"
- Go to "Bot" tab โ Click "Add Bot"
- Under "Privileged Gateway Intents", enable:
- โ Message Content Intent (required for auto-prompts)
- โ Server Members Intent
- โ Presence Intent
- Click "Reset Token" โ Copy and save securely
Step 2: Configure OAuth2 Scopes & Permissions โ
- Go to "OAuth2" โ "URL Generator"
- Select scopes:
- โ
bot - โ
applications.commands
- โ
- Select bot permissions:
- โ Send Messages
- โ Embed Links
- โ Read Message History
- โ Use Slash Commands
- โ Manage Messages (for auto-prompts)
- Copy generated URL
- Open URL in browser โ Select your server โ Authorize
Step 3: Get Discord IDs โ
Enable Developer Mode:
- Discord โ User Settings โ Advanced
- Enable "Developer Mode"
Get IDs by right-clicking:
- Server name โ "Copy Server ID" โ
DISCORD_GUILD_ID - #features channel โ "Copy ID" โ
DISCORD_FEATURE_CHANNEL_ID - #bugs channel โ "Copy ID" โ
DISCORD_BUG_CHANNEL_ID - #admin-monitor channel โ "Copy ID" โ
DISCORD_ADMIN_MONITOR_CHANNEL_ID
Step 4: Install Dependencies โ
cd discord-bot
npm installDependencies:
discord.js- Discord bot frameworkfirebase-admin- Firestore access@octokit/rest- GitHub APIdotenv- Environment variable loading
Step 5: Configure Environment Variables โ
For Local Development:
cp .env.testing .envEdit .env with your values:
# Discord Configuration
DISCORD_BOT_TOKEN=your_bot_token_here
DISCORD_CLIENT_ID=your_application_id_here
DISCORD_GUILD_ID=your_server_id_here
# Discord Channel IDs
DISCORD_FEATURE_CHANNEL_ID=123456789012345678
DISCORD_BUG_CHANNEL_ID=123456789012345678
DISCORD_ADMIN_MONITOR_CHANNEL_ID=123456789012345678
# Firebase
FIREBASE_PROJECT_ID=lantern-app-dev
# GitHub
GITHUB_TOKEN=ghp_your_github_personal_access_token
GITHUB_REPO=cattreedev/lantern_app
# GitHub Project V2 (Optional - defaults provided)
GITHUB_PROJECT_NAME=Lantern App
GITHUB_MILESTONE_NAME=PrototypeStep 6: Firebase Service Account Setup (Choose One Method) โ
Method 1: File Path (Recommended for Local)
- Go to Firebase Console โ lantern-app-dev project
- Project Settings โ Service Accounts โ "Generate New Private Key"
- Save to
~/repos/secrets/firebase/lantern-app-dev-firebase-adminsdk-*.json - Add to .env:bash
FIREBASE_SERVICE_ACCOUNT_PATH=~/repos/secrets/firebase/lantern-app-dev-firebase-adminsdk-*.json
Method 2: JSON String (Recommended for Deployment)
- Get service account JSON (same as above)
- Add to environment variables:bash
FIREBASE_SERVICE_ACCOUNT_KEY='{"type":"service_account","project_id":"lantern-app-dev",...}'
The bot uses FIREBASE_SERVICE_ACCOUNT_KEY if available, otherwise falls back to file path.
โ ๏ธ Never commit these files to Git! They're in .gitignore.
Step 7: Register Slash Commands โ
โ ๏ธ Critical: Must be done BEFORE commands work in Discord (one-time setup).
npm run registerExpected output:
Registering commands...
Successfully registered 3 application commands.After this, /feature, /bug, and /mystatus will appear in Discord.
Local Testing โ
Testing Setup โ
For testing features locally without affecting production:
- Create a separate test Discord server (or use existing test server)
- Invite the bot to your test server
- Create test channels (#features, #bugs, #admin-monitor)
- Get test channel IDs and update
.env.testing - Run locally with isolated test configuration
Testing Workflow โ
cd discord-bot
# Use test configuration
cp .env.testing .env
# Install dependencies (if first time)
npm install
# Register slash commands (one-time)
npm run register
# Run bot locally
npm start
# In a separate terminal, test by running Discord commands
# When done, stop with Ctrl+CWhat Happens During Local Testing โ
- โ Bot connects to test Discord guild (separate server)
- โ
Issues created in GitHub go to
Lantern App Testingproject - โ All data uses dev Firebase database (no production data touched)
- โ
Milestones tagged with
Testinglabel - โ Production bot and guilds completely unaffected
Testing Checklist โ
After deployment, test:
Slash Commands
- Type
/in any channel - See
/feature,/bug,/mystatus - Run
/featureand fill out modal - Submit
- Type
Verify Results
- โ
Message posted in
#featureschannel - โ
Notification in
#admin-monitorchannel - โ GitHub issue created with correct labels
- โ Firestore document created
- โ
Message posted in
Test Auto-Prompts
- Post a regular message in
#featuresor#bugs - Bot should reply with helpful prompt
- Click "Got it!" or wait 30 seconds
- Message should auto-delete
- Post a regular message in
Test
/mystatus- Run
/mystatuscommand - Should show your submission history
- Run
Deployment โ
Option A: Local Testing (Quick Start) โ
npm start- โ Immediate, no cost, easy debugging
- โ Must keep computer on, not production-ready
Option B: Railway (Recommended for Production) โ
Railway is a platform-as-a-service with generous free tier.
Setup Steps โ
Create Account
- Go to https://railway.app
- Sign up with GitHub
Create New Project
- Click "New Project" โ "Empty Project"
- Name it "lantern-discord-bot"
Deploy from GitHub
- In Railway project โ "New" โ "GitHub Repo"
- Select
cattreedev/lantern_app - Set root directory:
discord-bot
Add Environment Variables In Railway dashboard โ Variables:
DISCORD_BOT_TOKEN=your_token DISCORD_CLIENT_ID=your_client_id DISCORD_GUILD_ID=your_guild_id DISCORD_FEATURE_CHANNEL_ID=123... DISCORD_BUG_CHANNEL_ID=123... DISCORD_ADMIN_MONITOR_CHANNEL_ID=123... FIREBASE_PROJECT_ID=lantern-app-dev FIREBASE_SERVICE_ACCOUNT_PATH=/app/service-account.json GITHUB_TOKEN=ghp_... GITHUB_REPO=cattreedev/lantern_app GITHUB_PROJECT_NAME=Lantern App GITHUB_MILESTONE_NAME=PrototypeUpload Service Account
- Railway โ Settings โ Add Secret File
- Name:
service-account.json - Upload Firebase service account JSON
- Path:
/app/service-account.json
Deploy
- Railway auto-deploys. Monitor logs in dashboard.
Cost: Free tier gives 500 hours/month (sufficient for 24/7 bot). After: ~$5/month.
Option C: Self-Hosted Server (Advanced) โ
If you have a VPS or cloud VM:
# On your server
git clone https://github.com/cattreedev/lantern_app.git
cd lantern_app/discord-bot
npm install
# Copy service account
scp ~/repos/secrets/firebase/lantern-app-dev-service-account.json \
user@server:/path/to/lantern_app/discord-bot/
# Create .env file
nano .env # paste environment variables
# Run with PM2 (keeps bot alive)
npm install -g pm2
pm2 start bot.js --name lantern-bot
pm2 save
pm2 startup # enables autostart on rebootOption D: Heroku (Alternative) โ
heroku create lantern-discord-bot
heroku config:set DISCORD_BOT_TOKEN=xxx
heroku config:set FIREBASE_PROJECT_ID=lantern-app-dev
# ... set all other vars
git push heroku mainNote: Heroku no longer offers free tier. Railway or self-hosting recommended.
Usage โ
Submit a Feature Request โ
/featureModal fields:
- Title (required, max 100 chars)
- Description (required, max 1000 chars)
- Use Case (optional, max 500 chars)
- Priority (low/medium/high/critical)
- Impact (individual/small-group/all-users)
Report a Bug โ
/bugSame modal as feature requests, posted to #bugs channel instead.
Check Your Submissions โ
/mystatusShows your recent submissions with current status and GitHub links.
What Happens When You Submit โ
- Modal submission โ Bot validates input
- GitHub issue created โ Automatically formatted with labels
- Public channel post โ Appears in #features or #bugs
- Admin notification โ Posted to #admin-monitor (private)
- User confirmation โ You receive:
- Direct link to your submission
- Link to browse all issues
- Tip about using
/mystatus
Channel Setup Guidance โ
#features Channel
Topic:
๐ก Submit feature ideas using /feature commandPinned message:
Welcome to #features! ๐
Have an idea to improve Lantern? Submit it here!
**How to submit:**
1. Type `/feature` anywhere in this channel
2. Fill out the form that appears
3. Your request will be posted here and tracked on GitHub
**Need help?** Type `/mystatus` to see your submissions#bugs Channel
Topic:
๐ Report bugs using /bug commandPinned message:
Welcome to #bugs! ๐ง
Found a problem? Let us know!
**How to report:**
1. Type `/bug` anywhere in this channel
2. Describe the issue in the form
3. Your report will be posted here and tracked on GitHub
**Track your reports:** Use `/mystatus` commandGitHub Integration โ
GitHub Issue Format โ
Issues created with:
- Labels:
enhancement(for features) orbug,discord-submission - Milestone: Automatically added to "Prototype" milestone (configurable)
- GitHub Project: Automatically added to "Lantern App" project (configurable)
- Priority: Set in GitHub Projects V2 as P0 (critical), P1 (high), P2 (medium), or P3 (low)
- Body: Discord username, type, priority, impact, description, Firestore ID
GitHub Projects V2 Integration โ
The bot integrates with GitHub Projects V2 to:
- Add issues to project - Each new issue automatically added to configured project
- Set priority field - Maps Discord priority to GitHub project priority (P0-P3)
- Attach milestone - Adds issues to "Prototype" milestone by default
Requirements:
- GitHub Project V2 must exist with name matching
GITHUB_PROJECT_NAME(default: "Lantern App") - Project must have "Priority" single-select field with options: P0, P1, P2, P3
- Milestone named
GITHUB_MILESTONE_NAME(default: "Prototype") must exist in repository
Configuration:
# Optional: Change project name (defaults to "Lantern App")
GITHUB_PROJECT_NAME=My Project
# Optional: Change milestone name (defaults to "Prototype")
GITHUB_MILESTONE_NAME=MVPGitHub Access for Users โ
Current Setup: Private Repository with Team Access
The repository is private, so users need to be added to the GitHub organization with "Read" access.
What users CAN do (with Read access):
- โ View all issues
- โ Browse code (read-only)
- โ See issue status and comments
- โ Comment on issues
What users CANNOT do:
- โ Push code changes (requires Write permissions)
- โ Merge pull requests
- โ Modify repository settings
Setting Up Team Access:
- Add employees to your GitHub organization
- Grant "Read" access to the repository
- Non-technical staff can safely view but cannot modify code
Troubleshooting โ
Bot doesn't respond to commands โ
Check:
- Bot is online (
npm startrunning or Railway shows "running") - Slash commands are registered (
npm run register) - Bot has permission to view and send messages in channels
DISCORD_GUILD_IDmatches your server- Bot is in the server and has proper role permissions
Fix:
# Re-register commands
npm run register
# Restart bot
npm start # local
# or Railway: redeploy"Invalid interaction application command" error โ
- Re-run
npm run register - Wait a few minutes for Discord to propagate changes
- Restart bot
Slash commands don't appear in Discord โ
- Verify bot has
applications.commandsscope (see OAuth2 setup) - Run
npm run registeragain - Wait up to 1 hour for global propagation
- Check bot has permission in channels
"Missing Access" error โ
- Verify bot has permissions in channels
- Check channel IDs in
.envare correct - Ensure bot role is above channel permission overrides
GitHub issue creation fails โ
- Verify
GITHUB_TOKENis valid:- Go to GitHub โ Settings โ Developer settings โ Tokens
- Ensure token has
reposcope for private repositories - Check token hasn't expired
- Check
GITHUB_REPOformat:owner/repo(e.g.,cattreedev/lantern_app) - Verify rate limits: https://api.github.com/rate_limit
Firebase errors โ
- Verify service account JSON path is correct
- Check service account has Firestore permissions
- Ensure
FIREBASE_PROJECT_IDmatches your project - If using file path, check file exists at path
Auto-prompts don't work โ
- Enable "Message Content Intent" in Discord Developer Portal
- Bot needs permission to "Manage Messages" in channels
- Verify auto-prompt code is not disabled in bot.js
Bot goes offline โ
- Check Railway dashboard for errors
- Verify all environment variables are set correctly
- Check GitHub Actions workflows for deployment status
- Monitor PM2 logs:
pm2 logs lantern-bot
Monitoring & Maintenance โ
Checking Bot Status โ
Local:
- Check terminal output where
npm startis running
Railway:
- Dashboard โ Logs tab shows real-time logs
- Deployments tab shows deployment history
PM2 (Self-hosted):
pm2 status
pm2 logs lantern-bot
pm2 restart lantern-botRegular Maintenance โ
Monthly:
- Verify Discord bot token is still valid
- Check GitHub token hasn't expired
- Review Firebase quotas and costs
On Channel Changes:
- Update channel IDs in environment variables
- Restart bot or redeploy
Updating the Bot:
Local:
git pull
npm install
npm run register
npm startRailway:
git push # Auto-deploysPM2:
cd discord-bot
git pull
npm install
npm run register
pm2 restart lantern-botBackup & Recovery โ
Firestore automatically stores all submissions. No additional backup needed for Discord bot. However:
- Keep
.envfile safe (in.gitignore, never committed) - Store Firebase service account JSON in secure location
- Keep GitHub token in secure location
Analytics & Monitoring โ
Track submissions via Firestore:
- Collection:
discord_submissions - Document: One per submission with timestamp, user, type, status
- Query: Filter by date, type, priority, status
Security Checklist โ
- โ
.envfile is in.gitignore(never committed) - โ Discord bot token kept secure
- โ
GitHub token has minimal scope (
repoonly) - โ Firebase service account JSON protected
- โ Admin channel is private (only team members can view)
- โ Rate limiting enabled (prevents spam)
- โ Input validation on all fields
- โ User submissions tracked by Discord ID
FAQ โ
Q: Do I need to deploy to both dev and prod?
A: Yes, if you want separate environments. Use different .env files pointing to lantern-app-dev and lantern-app-prod Firebase projects.
Q: Can I use one bot for both environments?
A: No. Create separate bot applications for dev and prod to avoid mixing data.
Q: How much does Railway cost?
A: Free tier gives 500 hours/month. After that, ~$5/month for 24/7 uptime.
Q: What happens if the bot goes offline?
A: Users cannot use slash commands temporarily. When bot comes back online, commands resume. Firestore still stores any submissions made through web forms.
Q: How do I update slash commands?
A: Edit register-commands.js, then run npm run register again.
Q: Can I add more commands?
A: Yes, add to register-commands.js and bot.js, then run npm run register.
Q: What if I have more than 3 channels?
A: The bot currently supports 3 channels (features, bugs, admin-monitor). To add more, modify bot.js and add corresponding environment variables.
Related Documentation โ
Files โ
discord-bot/
โโโ bot.js # Main bot implementation
โโโ register-commands.js # Slash command registration
โโโ package.json # Dependencies
โโโ .env.example # Environment template
โโโ .env.testing # Test environment template
โโโ .gitignore # Git ignore patterns
โโโ README.md # Quick referenceSummary Checklist โ
After deploying, you should have:
- โ Bot online in Discord (green dot)
- โ
Slash commands
/feature,/bug,/mystatusavailable - โ Auto-prompts working for regular messages
- โ GitHub issues created with correct labels
- โ Priorities mapped to P0-P3 for GitHub Projects
- โ Submissions posted to #features and #bugs channels
- โ Admin notifications in #admin-monitor channel
- โ Firestore storing all submissions
- โ End-to-end tested
Total setup time: ~40 minutes
For additional help, contact the development team.