A sophisticated Discord bot that bridges GitHub webhooks with Discord notifications, providing rich embeds, role-based mentions, and engaging community interactions.
- Features
- Prerequisites
- Installation
- Configuration
- Database Setup
- GitHub Webhook Setup
- Discord Bot Setup
- Usage
- Commands
- Events
- API Endpoints
- Development
- Troubleshooting
- Contributing
- License
- GitHub Webhook Integration: Real-time notifications for issues and pull requests
- Rich Discord Embeds: Professional-looking notifications with issue details, labels, and metadata
- Role-Based Mentions: Tag specific roles when issues are created
- Multi-Repository Support: Connect multiple GitHub repositories to different Discord channels
- Secure Webhook Verification: HMAC-SHA256 signature validation for security
- Engaging Messages: 400+ randomized, meme-inspired announcement messages
- Welcome System: Automated welcome messages for new server members
- Interactive Commands: Slash commands and traditional prefix commands
- Visual Feedback: Color-coded embeds based on issue priority and type
- MongoDB Integration: Persistent storage for repository-channel mappings
- Express Server: Robust webhook handling with raw body parsing
- Error Handling: Comprehensive logging and graceful failure recovery
- Modular Architecture: Clean separation of concerns with utilities and events
- Node.js: Version 16.0.0 or higher
- MongoDB: Local installation or cloud service (MongoDB Atlas)
- GitHub Account: With repository access
- Discord Account: With server administrator privileges
- RAM: 512MB minimum, 1GB recommended
- Storage: 100MB for bot files + database
- Network: Stable internet connection for webhook delivery
git clone https://github.com/opencodeiiita/geekbot.git
cd geekbotnpm installCreate a .env file in the root directory:
DISCORD_TOKEN=your_discord_bot_token_here
MONGODB_URI=mongodb://localhost:27017/geekbot
WEBHOOK_SECRET=your_github_webhook_secret_here
PORT=3001# MongoDB should be running locally or use a cloud service
mongosh # or mongo
use geekbot| Variable | Description | Required | Example |
|---|---|---|---|
DISCORD_TOKEN |
Discord bot token from Developer Portal | β | MTEwMDAwMDAwMDAwMDAwMDAw.MEowL |
MONGODB_URI |
MongoDB connection string | β | mongodb://localhost:27017/geekbot |
WEBHOOK_SECRET |
GitHub webhook secret for verification | β | your-secret-key-here |
PORT |
Server port for webhook endpoint | β | 3001 |
The bot requires the following Discord permissions:
- Send Messages
- Embed Links
- Mention Everyone (for role mentions)
- Read Message History
- Use Slash Commands
The bot uses a single collection repolinks with the following schema:
{
guildId: String, // Discord server ID
repoKey: String, // Lowercase "owner/repo" format
repoName: String, // Original repository name
channelId: String, // Discord channel ID for notifications
mentionRoles: [String], // Array of role IDs to mention
lastChecked: Date // Timestamp of last activity
}// Connect to MongoDB
use geekbot
// View all repository links
db.repolinks.find()
// Remove a repository link
db.repolinks.deleteOne({ repoKey: "owner/repo" })- Go to your GitHub repository β Settings β Webhooks
- Click Add webhook
- Configure the following:
| Field | Value |
|---|---|
| Payload URL | https://your-domain.com/api/v1/discord-bot |
| Content type | application/json |
| Secret | Your webhook secret (same as .env file) |
| Events | Select: Issues, Pull requests |
The bot responds to:
issues.openedissues.closedissues.reopenedpull_request.openedpull_request.closedpull_request.reopened
The bot uses HMAC-SHA256 to verify webhook authenticity:
const signature = crypto
.createHmac('sha256', WEBHOOK_SECRET)
.update(rawBody)
.digest('hex');- Go to Discord Developer Portal
- Click New Application
- Give your bot a name (e.g., "GeekBot")
- Go to Bot section
- Click Add Bot
- Copy the Token (this is your
DISCORD_TOKEN) - Enable Message Content Intent (under Privileged Gateway Intents)
Generate an invite URL with the following permissions:
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=414464658496&scope=bot%20applications.commands
Replace YOUR_CLIENT_ID with your application's client ID.
Use the !register command to link GitHub repositories:
!register https://github.com/owner/repo #channel @role1 @role2
Example:
!register https://github.com/opencodeiiita/geekbot #github-notifications @contributors @maintainers
When an issue is created, the bot sends:
π Hello Contributors! @contributors @maintainers
π¨ CODE RED β This function just pulled a 'it works on my machine' and now production is crying...
[Rich Embed with Issue Details]
| Command | Description | Usage |
|---|---|---|
!register |
Link GitHub repo to Discord channel | !register <repo-url> <channel> [roles...] |
!ping |
Check bot latency | !ping |
!server |
Display server information | !server |
!user |
Display user information | !user [@user] |
| Command | Description |
|---|---|
/reload |
Reload bot commands |
/test-welcome |
Test welcome message |
| Event | Trigger | Action |
|---|---|---|
ready |
Bot starts | Logs connection status |
guildMemberAdd |
New member joins | Sends welcome message |
messageCreate |
Message sent | Processes commands |
interactionCreate |
Slash command used | Executes command |
| Event | Action |
|---|---|
issues.opened |
Creates rich embed notification |
issues.closed |
Sends closure notification |
issues.reopened |
Sends reopen notification |
pull_request.opened |
Creates PR embed notification |
pull_request.closed |
Sends PR closure notification |
pull_request.reopened |
Sends PR reopen notification |
POST /api/v1/discord-bot
Headers:
X-GitHub-Event: Event type (issues, pull_request)X-Hub-Signature-256: HMAC signature for verification
Body: GitHub webhook payload (JSON)
POST /back/api/v1/discord-bot # Alternative routing
geekbot/
βββ index.js # Main bot file
βββ commands/
β βββ utility/ # Bot commands
βββ events/ # Discord event handlers
βββ models/ # MongoDB schemas
βββ utils/
β βββ issueMessages.js # Message pools
βββ package.json
βββ .env # Environment variables
βββ README.md
# Install dependencies
npm install
# Start with auto-reload (if using nodemon)
npm run dev
# Or start normally
node index.jsThe project uses ESLint for code quality:
# Run linting
npx eslint index.js
# Fix auto-fixable issues
npx eslint index.js --fix- Commands: Add to
commands/utility/ - Events: Add to
events/directory - Messages: Modify
utils/issueMessages.js - Database: Update
models/schemas
# Check if bot is running
ps aux | grep node
# Check logs for errors
tail -f logs/bot.log
# Verify Discord token
echo $DISCORD_TOKEN# Test webhook endpoint
curl -X POST http://localhost:3001/api/v1/discord-bot \
-H "Content-Type: application/json" \
-d '{"test": "data"}'
# Check webhook secret
echo $WEBHOOK_SECRET# Test MongoDB connection
mongosh --eval "db.runCommand({ping: 1})"
# Check connection string
echo $MONGODB_URI- Public repos: Images work automatically
- Private repos: OpenGraph service cannot access private content
- Solution: Images are optional; embeds work without them
Enable verbose logging by setting:
DEBUG=geekbot:*- Database indexing: Ensure
repoKeyis indexed - Rate limiting: Implement webhook rate limiting for high-traffic repos
- Caching: Cache frequently accessed data
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run tests:
npm test - Submit a pull request
- Use ESLint configuration
- Follow conventional commit messages
- Add JSDoc comments for new functions
- Test all new features
# Run test suite
npm test
# Run specific tests
npm run test:unit
npm run test:integrationThis project is licensed under the ISC License - see the LICENSE file for details.
- Discord.js: Powerful Discord API wrapper
- Express: Robust web framework
- MongoDB: Flexible NoSQL database
- GitHub: Excellent webhook system
- Open Source Community: Inspiration and support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: This README
Built with β€οΈ for the open source community
Last updated: December 21, 2025