Skip to content

xxRockOnxx/discord-github-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Discord GitHub Bot

Manage GitHub Issues Without Leaving Discord

Go Version Discord GitHub License Docker

Features โ€ข Quick Start โ€ข Usage โ€ข Docker โ€ข Security


๐ŸŽฏ Why This Bot?

Stop context-switching between Discord and GitHub. Manage your entire issue workflow from the comfort of your Discord server. Whether you're tracking bugs, managing features, or collaborating with your team, this bot brings GitHub's power directly to Discord.

Built with security in mind โ€” Personal OAuth authentication ensures all actions are attributed correctly, and AES-256-GCM encryption keeps your tokens safe.

โœจ Features

๐Ÿ” Secure Authentication

  • Personal OAuth - Each user authenticates with their own GitHub account
  • AES-256-GCM Encryption - Tokens encrypted at rest
  • Ephemeral Auth Links - Private authentication messages

โšก Issue Management

  • โœ… Create issues with rich descriptions
  • ๐Ÿ“‹ List issues (open, closed, or all)
  • ๐Ÿ” View detailed issue information
  • โŒ Close issues directly from Discord
  • ๐Ÿ’ฌ Comment and collaborate seamlessly

๐ŸŽ›๏ธ Smart Configuration

  • Channel-Specific Defaults - Set repository per channel
  • Project Integration - Link to GitHub Projects with pagination and filtering
  • Modern Slash Commands - Intuitive autocomplete

๐Ÿณ Deployment Ready

  • Docker Support - One-command deployment
  • Docker Compose - Production-ready setup
  • Persistent Storage - Volume-mounted database

๐Ÿš€ Getting Started

Choose the best option for your needs:

โ˜๏ธ Use Hosted Version

Recommended for most users

โœ… Zero configuration required โœ… Always up-to-date โœ… Instant setup (1 click) โœ… No server costs

โžก๏ธ Invite Bot to Discord

Then jump to Usage to get started!

๐Ÿ  Self-Host

For advanced users

โœ… Full control over your data โœ… Custom modifications possible โœ… Run on private networks โœ… No external dependencies

โžก๏ธ Self-Hosting Guide

Requires Discord Bot App & GitHub OAuth App setup.

๐Ÿค” Which Option Should I Choose?

Feature Hosted Version Self-Hosted
Setup Time < 1 minute ~15-30 minutes
Technical Knowledge None required Basic Docker/Go knowledge
Cost Free Server costs (if applicable)
Maintenance Automatic Manual updates
Data Control Hosted by bot provider Full control
Custom Features Not available Modify as needed
Private Network โŒ โœ…

๐Ÿ’ก Not sure? Start with the hosted version - you can always self-host later!


๐Ÿ  Self-Hosting

โš ๏ธ Important: Self-hosting requires creating your own Discord Bot application in the Discord Developer Portal. This is different from the hosted version which uses a pre-configured bot application. You'll get your own invite link after setup.

โšก Quick Deploy (Docker - Recommended)

Prerequisites

  • Docker & Docker Compose installed
  • Discord Bot Application (Create one) - Required for self-hosting
  • GitHub OAuth App (Create one)

Deploy in 3 Steps

# 1. Clone and configure
git clone <your-repo>
cd discord-github-bot
cp .env.example .env

# 2. Edit .env with your credentials (see configuration guide below)
nano .env

# 3. Launch!
docker-compose up -d

Your bot is now running! View logs with docker-compose logs -f

๐Ÿ“– Detailed Self-Hosting Setup

Self-Hosting Configuration

Note: For self-hosting, you need to create your own Discord Bot application since you'll be running your own instance.

1. Create a Discord Bot Application

  1. Go to Discord Developer Portal
  2. Click "New Application" and give it a name
  3. Go to the "Bot" section and click "Add Bot"
  4. Under "Privileged Gateway Intents", enable:
    • โœ… SERVER MEMBERS INTENT
    • โœ… MESSAGE CONTENT INTENT
  5. Copy the bot token (you'll need this for DISCORD_BOT_TOKEN)
  6. Go to "OAuth2" > "General" and copy the Application ID (needed for DISCORD_APPLICATION_ID)
  7. Go to "OAuth2" > "URL Generator":
    • Select scopes: bot, applications.commands
    • Select bot permissions: Send Messages, Use Slash Commands
    • Copy the generated URL - this is your personal invite link for your self-hosted bot

2. Create a GitHub OAuth App

  1. Go to GitHub Settings > Developer settings > OAuth Apps
  2. Click "New OAuth App"
  3. Fill in the details:
    • Application name: Discord GitHub Bot
    • Homepage URL: http://localhost:8080 (or your domain)
    • Authorization callback URL: http://localhost:8080/callback (or your domain)
  4. Click "Register application"
  5. Copy the Client ID
  6. Generate a new client secret and copy it

3. Configure the Bot

  1. Copy the example environment file:

    cp .env.example .env
  2. Edit .env and fill in your credentials:

    # Discord Configuration
    DISCORD_BOT_TOKEN=your_discord_bot_token
    DISCORD_APPLICATION_ID=your_application_id
    
    # GitHub OAuth Configuration
    GITHUB_CLIENT_ID=your_github_client_id
    GITHUB_CLIENT_SECRET=your_github_client_secret
    GITHUB_REDIRECT_URL=http://localhost:8080/callback
    # For Docker: GITHUB_REDIRECT_URL=http://your-domain.com/callback
    
    # Generate a random 32-byte encryption key
    ENCRYPTION_KEY=your_32_character_encryption_key
    
    # Server Configuration (optional)
    OAUTH_SERVER_PORT=8080
    OAUTH_SERVER_HOST=localhost
    # For Docker: OAUTH_SERVER_HOST=0.0.0.0
    
    # Public URL - The publicly accessible URL for OAuth callbacks
    PUBLIC_URL=http://localhost:8080
    # For Docker/Production: PUBLIC_URL=https://your-domain.com
    
    # Database (optional)
    DATABASE_PATH=./bot.db
    # For Docker: DATABASE_PATH=/home/botuser/data/bot.db
  3. Generate a secure encryption key:

    # On Linux/Mac:
    openssl rand -base64 32 | head -c 32
    
    # Or use Go:
    go run -c 'package main; import ("crypto/rand"; "encoding/base64"; "fmt"); func main() { b := make([]byte, 32); rand.Read(b); fmt.Println(base64.StdEncoding.EncodeToString(b)[:32]) }'

4. Install Dependencies

go mod download

5. Run the Bot

Option A: Run with Go (Local Development)

The bot automatically loads environment variables from the .env file using godotenv:

go run main.go

Or build and run:

go build -o discord-github-bot
./discord-github-bot

Option B: Run with Docker

Using Docker Compose (recommended):

# Build and start the container
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the container
docker-compose down

Using Docker directly:

# Build the image
docker build -t discord-github-bot .

# Run the container
docker run -d \
  --name discord-github-bot \
  -p 8080:8080 \
  --env-file .env \
  -v bot-data:/home/botuser/data \
  discord-github-bot

# View logs
docker logs -f discord-github-bot

# Stop the container
docker stop discord-github-bot
docker rm discord-github-bot

๐Ÿ“š Usage

For Hosted Version Users: If you invited the hosted bot, start here!

For Self-Hosters: These commands work the same way on your self-hosted instance.

๐ŸŽฏ Getting Started

The first time you use the bot, authenticate with your GitHub account:

/gh-auth          # Get your personal OAuth link (only you can see it)

Click the link, authorize on GitHub, and you're ready! To revoke access later:

/gh-unauth        # Remove authentication

๐Ÿ”’ Privacy First: Authentication links are ephemeral (only visible to you)

2๏ธโƒฃ Configure Channel Defaults

Set up defaults so you don't repeat yourself:

/gh-set-repo repo:owner/repository    # Set default repo for this channel
/gh-set-project project:123           # Link to GitHub Project

๐ŸŽฎ Command Reference

CommandDescriptionExample
/gh-issue-create Create a new issue /gh-issue-create title:"Login bug" body:"Users can't sign in"
/gh-issue-list List issues (open/closed/all), with pagination and filtering /gh-issue-list state:open
/gh-issue-view View detailed issue info /gh-issue-view number:42
/gh-issue-close Close an issue with a reason (completed, not_planned, or duplicate) /gh-issue-close number:42 state_reason:completed
/gh-issue-comment Add a comment to an issue /gh-issue-comment number:42 comment:"Fixed!"
/gh-project-item-list List project items (open/closed/all), with pagination and filtering /gh-project-item-list project:123 state:open
/gh-project-item-create Create a new project item /gh-project-item-create project:123 title:"New Feature" body:"Implement X"
/gh-project-item-view View detailed project item information /gh-project-item-view project:123 item-id:456
/gh-project-item-archive Archive a project item /gh-project-item-archive project:123 item-id:456

๐Ÿ’ก Pro Tip: All commands support optional repo:owner/repository parameter to override channel defaults


๐Ÿ—๏ธ Architecture

discord-github-bot/
โ”œโ”€โ”€ ๐ŸŽฏ main.go                      # Application entry point
โ”œโ”€โ”€ ๐Ÿ“ฆ internal/
โ”‚   โ”œโ”€โ”€ config/                     # Configuration management
โ”‚   โ”œโ”€โ”€ database/                   # SQLite + encrypted token storage
โ”‚   โ”œโ”€โ”€ oauth/                      # GitHub OAuth flow handler
โ”‚   โ””โ”€โ”€ bot/                        # Discord bot & command handlers
โ”œโ”€โ”€ ๐Ÿณ Dockerfile                   # Container configuration
โ”œโ”€โ”€ ๐Ÿณ docker-compose.yml           # Orchestration setup
โ””โ”€โ”€ ๐Ÿ“‹ .env.example                 # Configuration template
Click to view detailed architecture

Component Overview

  • config/ - Loads and validates environment variables
  • database/ - SQLite with AES-256-GCM encrypted token storage
  • oauth/ - Handles GitHub OAuth 2.0 flow with state validation
  • bot/ - Discord bot initialization and slash command routing

Data Flow

Discord User โ†’ /command โ†’ Bot Handler โ†’ GitHub API
                                โ†“
                         Database (encrypted tokens)

๐Ÿ”’ Security

Feature Implementation
๐Ÿ” Token Encryption AES-256-GCM encryption at rest
๐Ÿ‘ค Personal Auth Each user uses their own GitHub account
๐Ÿ™ˆ Ephemeral Messages Auth links visible only to requesting user
โœ… OAuth 2.0 Standard flow with state validation
๐Ÿ›ก๏ธ No Shared Secrets Zero token sharing between users

โš ๏ธ Known Limitations

  • ๐Ÿ“Š GitHub Projects API support is limited (partial implementation)
  • ๐ŸŒ OAuth server requires public accessibility for production
  • ๐Ÿ“„ Issue listings capped at 10 most recent per query
  • ๐Ÿงช Consider using ngrok for local testing

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

# 1. Fork & clone
git clone https://github.com/xxRockOnxx/discord-github-bot.git

# 2. Create a feature branch
git checkout -b feature/amazing-feature

# 3. Make your changes & commit
git commit -m "Add amazing feature"

# 4. Push & create PR
git push origin feature/amazing-feature

Development Guidelines

  • โœ… Write tests for new features
  • ๐Ÿ“ Update documentation as needed
  • ๐ŸŽจ Follow existing code style
  • ๐Ÿ” Test thoroughly before submitting

๐Ÿ”ง Advanced Self-Hosting

Docker Management Commands

Common Docker Operations

# Start the bot
docker-compose up -d

# View logs
docker-compose logs -f

# Restart the bot
docker-compose restart

# Stop the bot
docker-compose down

# Update to latest version
git pull
docker-compose down
docker-compose build --no-cache
docker-compose up -d

Important Docker Environment Variables

OAUTH_SERVER_HOST=0.0.0.0              # Accept external connections
DATABASE_PATH=/home/botuser/data/bot.db # Use mounted volume
PUBLIC_URL=https://your-domain.com      # Your public URL for OAuth
Running Without Docker (Go)

Local Development

# Install dependencies
go mod download

# Run directly
go run main.go

# Or build and run
go build -o discord-github-bot
./discord-github-bot

The bot automatically loads .env file for configuration.

Production Deployment Tips

For Production Self-Hosting:

  1. Use a reverse proxy (nginx/Caddy) for HTTPS
  2. Set up a domain pointing to your server
  3. Configure OAuth redirect URL to use HTTPS
  4. Enable automatic restarts with systemd or Docker restart policies
  5. Set up log rotation to prevent disk space issues
  6. Back up your database regularly (it contains encrypted tokens)

Example nginx config:

server {
    listen 443 ssl;
    server_name bot.yourdomain.com;

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

๐Ÿ› ๏ธ Troubleshooting

โŒ Bot doesn't respond to commands
  • โœ… Check bot permissions in Discord server settings
  • โœ… Verify slash commands registered (check startup logs)
  • โœ… Confirm DISCORD_BOT_TOKEN and DISCORD_APPLICATION_ID are correct
  • โœ… Ensure bot has "Use Slash Commands" permission
๐Ÿ” Authentication fails
  • โœ… Verify GitHub OAuth App credentials (GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET)
  • โœ… Confirm redirect URL matches exactly (http vs https matters!)
  • โœ… Check OAuth server is accessible at configured host/port
  • โœ… For Docker: Ensure port 8080 is exposed and accessible externally
  • โœ… Try using ngrok for local testing
๐Ÿ’พ Database errors
  • โœ… Ensure DATABASE_PATH directory exists and is writable
  • โœ… Verify ENCRYPTION_KEY is exactly 32 characters
  • โœ… Check file permissions: chmod 644 bot.db
  • โœ… For Docker: Verify volume is mounted correctly (docker volume ls)
๐Ÿณ Docker-specific issues

Container exits immediately:

docker-compose logs      # Check for error messages
docker logs discord-github-bot

Port already in use:

  • Change OAUTH_SERVER_PORT in .env
  • Or modify port mapping in docker-compose.yml: "8081:8080"

Database not persisting:

docker volume ls         # Verify volume exists
docker-compose down -v   # Remove and recreate
docker-compose up -d

๐Ÿ“„ License

MIT License - Free to use, modify, and distribute. See LICENSE for details.


๐Ÿ’ฌ Support & Community

Using the Hosted Version?

  • โ˜๏ธ Questions or issues? The hosted bot is provided as-is
  • ๐Ÿ’ก Feature requests? Open a discussion

Self-Hosting?

Show Your Support

  • โญ Star this repo if you find it useful!
  • ๐Ÿ”„ Share with others who might benefit
  • ๐Ÿ“ข Spread the word in your communities

Made with โค๏ธ for the Discord & GitHub communities

โฌ† Back to Top

About

Manage GitHub Issues Without Leaving Discord

Resources

Stars

Watchers

Forks

Contributors