A Discord bot that allows users to list and create GitHub issues directly from Discord. The bot associates Discord users with their GitHub issues for easy tracking.
- List GitHub issues from a specified repository (with state filtering)
- Create new GitHub issues using a structured form with fields for:
- Operating System (OSX/Windows/Linux)
- Cline Version
- What Happened
- Steps to Reproduce
- Close GitHub issues (with optional reason)
- Associate Discord users with their GitHub issues
- Persistent storage of user-issue associations
- Uses GitHub App authentication for better security and permissions
- Docker support for easy deployment
- Node.js (v16.9.0 or higher) OR Docker
- A Discord account and a registered Discord application/bot
- A GitHub account with a registered GitHub App
-
Clone this repository:
git clone <repository-url> cd gitbot
-
Install dependencies:
npm install
-
Clone this repository:
git clone <repository-url> cd gitbot
-
Build and run with Docker Compose:
# Build the container docker-compose build # Start the bot docker-compose up -d # View logs docker-compose logs -f # Stop the bot docker-compose down
The bot's data will be persisted in the local ./data
directory.
Copy the .env.example
file to .env
and fill in your credentials:
# Discord Configuration
DISCORD_TOKEN=your_discord_bot_token_here
DISCORD_CLIENT_ID=your_discord_application_id
# GitHub App Configuration
GITHUB_APP_ID=your_github_app_id
# Use either GITHUB_APP_PRIVATE_KEY or GITHUB_APP_PRIVATE_KEY_PATH
# Option 1: Private key as a string (replace newlines with \n)
# GITHUB_APP_PRIVATE_KEY=-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA1c7+9z5Pad7OejecsQ0bu...E8tmYk9\n-----END RSA PRIVATE KEY-----
# Option 2: Path to private key file (recommended)
GITHUB_APP_PRIVATE_KEY_PATH=path/to/private-key.pem
GITHUB_APP_INSTALLATION_ID=your_github_app_installation_id
# Default GitHub Repository (format: owner/repo)
DEFAULT_GITHUB_REPO=owner/repo
- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Go to the "Bot" tab and click "Add Bot"
- Under the "TOKEN" section, click "Copy" to copy your bot token
- From the "General Information" tab, copy your "Application ID" (this is your DISCORD_CLIENT_ID)
- Enable the following Privileged Gateway Intents:
- SERVER MEMBERS INTENT
- MESSAGE CONTENT INTENT
- Go to GitHub Settings > Developer settings > GitHub Apps
- Click "New GitHub App" and fill in the required information:
- GitHub App name: Choose a unique name
- Homepage URL: Can be your GitHub profile or repository URL
- Webhook: Disable for now (uncheck "Active")
- Permissions:
- Repository permissions:
- Issues: Read & Write
- Metadata: Read-only
- Repository permissions:
- Click "Create GitHub App"
- After creation, note your "App ID" from the app's settings page
- Generate a private key by clicking "Generate a private key" and save the downloaded file
- Install the app on your account or organization by clicking "Install App"
- After installation, note the "Installation ID" from the URL in your browser:
- The URL will look like:
https://github.com/settings/installations/12345678
- The number at the end (e.g.,
12345678
) is your Installation ID
- The URL will look like:
You have two options for providing the GitHub App private key:
- Save the private key file (
.pem
) that you downloaded from GitHub in a secure location - If using Docker:
- Place the private key file in your project directory
- Uncomment the private key volume mount in
docker-compose.yml
:volumes: - ./data:/data - ./keys/private-key.pem:/keys/private-key.pem:ro
- Set the path in your
.env
file:GITHUB_APP_PRIVATE_KEY_PATH=/usr/src/app/private-key.pem # For Docker # or GITHUB_APP_PRIVATE_KEY_PATH=./private-key.pem # For local installation
- Open the private key file (
.pem
) in a text editor - Copy all the content (including the
-----BEGIN RSA PRIVATE KEY-----
and-----END RSA PRIVATE KEY-----
lines) - Replace all newlines with
\n
for a single-line entry - Set the
GITHUB_APP_PRIVATE_KEY
variable in your.env
file:GITHUB_APP_PRIVATE_KEY=-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA1c7+9z5Pad7OejecsQ0bu...E8tmYk9\n-----END RSA PRIVATE KEY-----
- Go to the Discord Developer Portal
- Select your application and go to the "OAuth2" tab
- Under "URL Generator", select the following scopes:
bot
applications.commands
- Under "Bot Permissions", select:
- "Send Messages"
- "Embed Links"
- "Read Message History"
- Copy the generated URL and open it in your browser to invite the bot to your server
# Start the bot
npm start
# Start the bot with nodemon (auto-restart on file changes)
npm run dev
# Start the bot
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the bot
docker-compose down
The bot will automatically register its commands on startup. You can also manually register commands using:
# Local installation
node register-commands.js
# Docker
docker-compose exec bot node register-commands.js
To remove all commands from Discord (both global and guild-specific):
# Local installation
node unregister-commands.js
# Docker
docker-compose exec bot node unregister-commands.js
This utility is useful for:
- Cleaning up during development
- Removing outdated commands
- Troubleshooting command registration issues
- Completely resetting your bot's commands
The bot provides a variety of commands for both regular users and administrators. For a complete list of all available commands with detailed descriptions and options, see COMMANDS.md.
The bot includes an admin system that allows for user management and additional administrative commands:
-
Bot Owner: Each server can have one bot owner, who has full control over the bot's administrative functions.
- The first server administrator to use the
/register-bot
command becomes the bot owner. - Once an owner is registered, the
/register-bot
command is no longer available.
- The first server administrator to use the
-
Administrators: The bot owner can designate other users as administrators.
- Administrators can use most admin commands except removing other admins.
- Administrators cannot be blocked from using the bot.
-
User Management: The bot owner and administrators can block users from using the bot.
- Blocked users cannot use any of the bot's commands.
- The bot owner and administrators cannot be blocked.
-
Server-Specific Settings: All admin settings are server-specific, allowing the bot to be used in multiple servers with different configurations.
The bot stores data in the following directories:
data/storage/
- Associations between Discord users and GitHub issuesdata/admin/
- Admin system configuration (owners, admins, blocked users)data/keys/
- Key location for private-keys
When using Docker, these directories are persisted through a volume mount to ./data
in your project directory.
MIT