Complete step-by-step guide for organizations setting up Gitcord
- Prerequisites
- Step 1: Create GitHub Token (PAT)
- Step 2: Create Discord Bot
- Step 3: Invite Bot to Discord Server
- Step 4: Configure Gitcord
- Step 5: Run Gitcord
- Security Best Practices
- Troubleshooting
Before starting, ensure you have:
- ✅ Python 3.11+ installed
- ✅ Access to your GitHub organization
- ✅ Admin access to your Discord server
- ✅ GitHub account with organization permissions
- ✅ Discord Developer Portal access
- Go to GitHub → Settings → Developer Settings
- Click Personal Access Tokens → Fine-grained tokens
- Click Generate new token
Token Name: Gitcord Bot (or your preferred name)
Expiration: Set appropriate expiration (recommended: 90 days or custom)
Repository Access:
- Select Only select repositories (recommended) OR
- Select All repositories (if you want org-wide access)
Required Permissions:
| Permission | Access Level | Why |
|---|---|---|
| Contents | Read & Write | Needed for GitHub snapshots |
| Issues | Read & Write | Assign issues to contributors |
| Pull requests | Read & Write | Request reviews, check merge status |
| Metadata | Read | Required automatically by GitHub |
Note: For testing locally, Read permissions are sufficient. Write permissions are needed for:
- Issue assignments
- Review requests
- GitHub snapshots
- Click Generate token
⚠️ IMPORTANT: Copy the token immediately (you won't see it again)- Save it securely (we'll use it in Step 4)
- Go to Discord Developer Portal
- Click New Application
- Enter application name:
Gitcord(or your preferred name) - Click Create
- Go to Bot section (left sidebar)
- Click Add Bot
- Click Yes, do it!
Bot Username: Gitcord (or your preferred name)
Public Bot: ❌ Uncheck (unless you want others to invite it)
Requires OAuth2 Code Grant: ❌ Uncheck
Go to Bot → Privileged Gateway Intents
✅ REQUIRED:
- ✅ Server Members Intent (required for role management and member reading)
❌ NOT REQUIRED:
- ❌ Presence Intent
- ❌ Message Content Intent (only needed if reading message text; Gitcord uses slash commands)
Note: Since Gitcord primarily uses slash commands, Message Content Intent is NOT required unless you enable PR preview channels.
If you need a new bot token:
- Click Reset Token
⚠️ IMPORTANT: Copy the token immediately- Save it securely (we'll use it in Step 4)
- Go to OAuth2 → URL Generator (left sidebar)
✅ REQUIRED Scopes:
- ✅ bot (bot functionality)
- ✅ applications.commands (slash commands)
❌ DO NOT SELECT:
- ❌ bot (with Administrator) - Never use Administrator!
✅ REQUIRED Permissions:
- ✅ Manage Roles (for role automation based on contributions)
- ✅ View Channels (to read server structure)
- ✅ Send Messages (for notifications and responses)
- ✅ Embed Links (for rich embeds in commands)
- ✅ Read Message History (for PR preview detection if enabled)
- ✅ Use Slash Commands (required for all commands)
- ✅ Add Reactions (optional, for UI feedback)
❌ DO NOT SELECT:
- ❌ Administrator (over-permission, security risk)
- ❌ Manage Server (not needed)
- ❌ Kick Members (not needed)
- ❌ Ban Members (not needed)
- ❌ Manage Channels (not needed)
- ❌ Manage Webhooks (not needed)
- ❌ Voice Permissions (not needed)
- Copy the generated URL at the bottom
- Open the URL in your browser
- Select your Discord server
- Click Authorize
- Complete CAPTCHA if prompted
After inviting the bot:
- Go to your Discord server
- Server Settings → Roles
- Find the Gitcord bot role
- Drag it ABOVE any roles it needs to manage
- Example: If bot assigns "Contributor" role, bot role must be above "Contributor"
Why: Discord requires roles to be higher in hierarchy to manage lower roles. If bot role is too low, role management will fail silently.
# Clone the repository
git clone https://github.com/AOSSIE-Org/Gitcord-GithubDiscordBot.git
cd Gitcord-GithubDiscordBot
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install Gitcord
pip install -e .Create a .env file in the project root:
cp .env.example .envEdit .env and add your tokens:
GITHUB_TOKEN=your_github_token_here
DISCORD_TOKEN=your_discord_bot_token_here.env to git. It's already in .gitignore.
Copy the example config:
cp config/example.yaml config/my-org-config.yamlEdit config/my-org-config.yaml:
runtime:
mode: "dry-run" # Start with dry-run for safety
log_level: "INFO"
data_dir: "./data/my-org"
github_adapter: "ghdcbot.adapters.github.rest:GitHubRestAdapter"
discord_adapter: "ghdcbot.adapters.discord.api:DiscordApiAdapter"
storage_adapter: "ghdcbot.adapters.storage.sqlite:SqliteStorage"
github:
org: "your-org-name" # Your GitHub organization name
token: "${GITHUB_TOKEN}" # From .env file
api_base: "https://api.github.com"
permissions:
read: true
write: true # Enable for issue assignments and snapshots
discord:
guild_id: "YOUR_DISCORD_GUILD_ID" # Right-click server → Copy Server ID
token: "${DISCORD_TOKEN}" # From .env file
permissions:
read: true
write: true
notifications:
enabled: true
issue_assignment: true
pr_review_requested: true
pr_review_result: true
pr_merged: true
channel_id: null # null = DM, or set channel ID for channel posting
scoring:
period_days: 30 # Scoring period in days
weights:
issue_opened: 3
pr_opened: 5
pr_reviewed: 2
comment: 1
pr_merged: 10
role_mappings:
- discord_role: "Contributor"
min_score: 10
- discord_role: "Maintainer"
min_score: 40
assignments:
review_roles:
- "Maintainer"
issue_assignees:
- "Mentor" # Roles that can use /assign-issue, /sync, /issue-requests
snapshots:
enabled: true
repo_path: "your-org/gitcord-data" # Repository for GitHub snapshots
branch: "main"Method 1: Discord Desktop/Web
- Enable Developer Mode: User Settings → Advanced → Developer Mode ✅
- Right-click your Discord server icon
- Click Copy Server ID
Method 2: Discord Mobile
- Enable Developer Mode in settings
- Long-press server icon → Copy Server ID
First, test in dry-run mode (safe, no changes):
python -m ghdcbot.cli --config config/my-org-config.yaml run-onceExpected Output:
- ✅ Reads GitHub events
- ✅ Reads Discord members/roles
- ✅ Generates audit reports in
data/my-org/reports/ - ✅ No mutations (no role changes, no issue assignments)
Check Reports:
data/my-org/reports/audit.json- Machine-readable reportdata/my-org/reports/audit.md- Human-readable report
Review the reports to see what changes would be made.
Start the Discord bot (for slash commands):
python -m ghdcbot.cli --config config/my-org-config.yaml botExpected Output:
Bot ready; slash commands synced for guild YOUR_GUILD_ID: ['link', 'verify-link', ...]
The bot will stay online and respond to slash commands.
To run in background:
nohup python -m ghdcbot.cli --config config/my-org-config.yaml bot > bot.log 2>&1 &Once you've verified everything works in dry-run:
- Edit
config/my-org-config.yaml - Change
mode: "dry-run"tomode: "active" - Run
run-onceagain to apply changes
- Add/remove Discord roles
- Assign GitHub issues
- Request PR reviews
Only enable after reviewing dry-run reports!
- ✅ Use fine-grained GitHub tokens (not classic tokens)
- ✅ Store tokens in
.envfile (never commit to git) - ✅ Use minimal permissions (only what's needed)
- ✅ Start with dry-run mode before going active
- ✅ Review audit reports before enabling writes
- ✅ Rotate tokens regularly (every 90 days recommended)
- ✅ Use Server Members Intent only (not all intents)
- ✅ Keep bot role above managed roles in Discord
- ❌ Never commit tokens to GitHub
- ❌ Never use Administrator permission
- ❌ Never use classic GitHub tokens (use fine-grained)
- ❌ Never share tokens in screenshots or public channels
- ❌ Never enable active mode without testing dry-run first
- ❌ Never give bot more permissions than needed
- Tokens stored in
.envfile -
.envis in.gitignore(verify it's not tracked) - Tokens not hardcoded in config files
- Fine-grained GitHub token (not classic)
- Minimal Discord permissions (no Administrator)
- Tokens have expiration dates set
- Tokens are rotated regularly
Problem: Slash commands don't appear or show "application did not respond"
Solutions:
- ✅ Verify bot is running:
ps aux | grep ghdcbot - ✅ Check bot logs for errors
- ✅ Wait 30 seconds after starting bot (commands need to sync)
- ✅ Verify
applications.commandsscope is selected in invite URL - ✅ Re-invite bot with correct scopes
Problem: Bot can't add/remove roles
Solutions:
- ✅ Verify bot role is above managed roles in Discord Role settings
- ✅ Check bot has Manage Roles permission
- ✅ Verify
discord.permissions.write: truein config - ✅ Check bot is in active mode (not dry-run)
- ✅ Check bot logs for permission errors
Problem: "GitHub permission or visibility issue"
Solutions:
- ✅ Verify GitHub token has correct permissions
- ✅ Check token hasn't expired
- ✅ Verify token has access to organization repos
- ✅ Check rate limits (GitHub API has rate limits)
- ✅ Verify
github.permissions.read: truein config
Problem: "Discord permission issue" or 403 errors
Solutions:
- ✅ Verify bot has required permissions (Manage Roles, View Channels)
- ✅ Check Server Members Intent is enabled
- ✅ Verify bot token is correct
- ✅ Check bot is still in server (not kicked)
- ✅ Verify guild_id is correct
Problem: /link or /verify-link commands fail
Solutions:
- ✅ Verify user has verified Discord ↔ GitHub link
- ✅ Check verification code is in GitHub bio or public gist
- ✅ Verify code hasn't expired (10 minutes default)
- ✅ Check storage is initialized:
storage.init_schema() - ✅ Review bot logs for specific errors
Problem: GitHub snapshots not appearing in repo
Solutions:
- ✅ Verify
snapshots.enabled: truein config - ✅ Check GitHub token has Contents: Write permission
- ✅ Verify
snapshots.repo_pathis correct format:owner/repo - ✅ Check bot has write access to snapshot repo
- ✅ Review logs for snapshot errors (non-blocking, won't stop run-once)
# Test run (dry-run, safe)
python -m ghdcbot.cli --config config/my-org-config.yaml run-once
# Run Discord bot
python -m ghdcbot.cli --config config/my-org-config.yaml bot
# Check identity status
python -m ghdcbot.cli --config config/my-org-config.yaml identity status --discord-user-id USER_ID
# Export audit logs
python -m ghdcbot.cli --config config/my-org-config.yaml export-audit --format mdFor Contributors:
/link- Link Discord to GitHub/verify-link- Verify GitHub link/verify- Check verification status/status- Show status and roles/summary- Show contribution metrics/request-issue- Request issue assignment
For Mentors:
/assign-issue- Assign issue to user/issue-requests- Review pending requests/sync- Manually sync GitHub events
- Example config:
config/example.yaml - Your config:
config/my-org-config.yaml(create your own) - Environment:
.env(create from.env.example)
After installation:
- ✅ Run first
run-oncein dry-run mode - ✅ Review
data/my-org/reports/audit.md - ✅ Test identity linking with
/linkand/verify-link - ✅ Verify role mappings match your Discord roles
- ✅ Test issue assignment flow
- ✅ Enable active mode when ready
- ✅ Set up cron job or scheduled task for
run-once
- Documentation: See README.md and TECHNICAL_DOCUMENTATION.md
- Issues: GitHub Issues
- Discord: Join our Discord server for support
🎉 Congratulations! You've successfully installed Gitcord. Start with dry-run mode and review reports before enabling active mode.