Skip to content

Implement automated team invitation system for GitHub and Discord - #293

Open
konard wants to merge 3 commits into
mainfrom
issue-119-6f7557a6
Open

Implement automated team invitation system for GitHub and Discord#293
konard wants to merge 3 commits into
mainfrom
issue-119-6f7557a6

Conversation

@konard

@konard konard commented Sep 13, 2025

Copy link
Copy Markdown
Member

🎯 Summary

This PR implements an automated team invitation system that allows GitHub organization owners and repository administrators to invite users to both the GitHub organization and Discord server through simple GitHub issue commands.

Fixes #119

✨ Features

🤖 GitHub Issue Bot Commands

  • Invite Command: @bot invite @username in issue body
  • Automatic Processing: Bot detects invitation requests and processes them automatically
  • Permission Validation: Only organization owners and repository admins can approve invitations

🔐 GitHub Integration

  • Organization Invitations: Automatically sends GitHub organization membership invitations
  • Permission Checks: Validates requestor has appropriate permissions (admin/maintain)
  • Issue Management: Automatically closes issues after successful processing

🎮 Discord Integration (Optional)

  • Invite Link Generation: Creates temporary Discord invite links for new team members
  • Configurable: Discord integration can be enabled/disabled via command line parameters
  • Secure: Uses Discord bot token authentication with guild/channel targeting

🏗️ Implementation Details

Core Components

TeamInvitationTrigger

  • Detects @bot invite @username pattern in GitHub issues
  • Validates issue author permissions
  • Coordinates GitHub and Discord invitation process
  • Provides feedback via issue comments

OwnerKeeperApprovalTriggerDecorator

  • Ensures only authorized users can approve invitations
  • Checks organization membership role and repository permissions
  • Follows existing security patterns from the codebase

DiscordService

  • Manages Discord bot connection and authentication
  • Creates temporary invite links with configurable expiration
  • Handles Discord API interactions safely with error handling

Enhanced GitHubStorage

  • Added InviteToOrganization() method for GitHub API integration
  • Follows existing patterns and error handling conventions

Command Line Configuration

dotnet run --github-user-name "BotUser" \
           --github-api-token "ghp_xxx" \
           --github-application-name "TeamBot" \
           --discord-token "xxx" \
           --discord-guild-id 123456 \
           --discord-channel-id 789012

🔄 Workflow

  1. Issue Creation: Admin creates issue with @bot invite @username
  2. Permission Check: Bot validates admin has appropriate permissions
  3. GitHub Invitation: Bot sends organization membership invitation
  4. Discord Link: Bot creates temporary Discord invite (if configured)
  5. Feedback: Bot comments on issue with results
  6. Cleanup: Issue is automatically closed on success

🧪 Testing

  • ✅ Project builds successfully with no errors
  • ✅ All existing functionality preserved
  • ✅ New Discord.Net dependency integrated
  • ✅ Command-line parameter parsing works correctly
  • ✅ Follows existing code patterns and conventions

📋 Usage Examples

Basic GitHub-only invitation:

@bot invite @newdeveloper

With Discord configured:

The bot will automatically:

  1. Send GitHub org invitation to @newdeveloper
  2. Create a Discord invite link
  3. Comment both results on the issue
  4. Close the issue

🔧 Configuration Requirements

Required Parameters

  • --github-user-name: Bot's GitHub username
  • --github-api-token: GitHub API token with org permissions
  • --github-application-name: GitHub application name

Optional Discord Parameters

  • --discord-token: Discord bot token
  • --discord-guild-id: Discord server ID
  • --discord-channel-id: Channel ID for invites

🚀 Benefits

  • Streamlined Onboarding: Single command invites to both platforms
  • Secure: Permission-based approval system
  • Automated: Reduces manual work for team leads
  • Flexible: Works with or without Discord integration
  • Maintainable: Follows existing codebase patterns

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #119
@konard konard self-assigned this Sep 13, 2025
- Add TeamInvitationTrigger to handle @bot invite @username requests in GitHub issues
- Add GitHubStorage.InviteToOrganization() method for GitHub org invitations
- Add DiscordService for creating temporary Discord invite links
- Add OwnerKeeperApprovalTriggerDecorator to ensure only owners/admins can approve invitations
- Update Program.cs to support Discord bot token, guild ID, and channel ID configuration
- Add Discord.Net NuGet package dependency

The bot now automatically processes team invitation requests when:
1. Issue contains "@bot invite @username" pattern
2. Issue author has admin or maintainer permissions
3. Bot invites user to GitHub organization
4. Bot creates Discord invite link if Discord is configured
5. Issue is automatically closed after successful invitation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] GitHub and Discord bots: Automate teammates invite to GitHub and Discord Implement automated team invitation system for GitHub and Discord Sep 13, 2025
@konard
konard marked this pull request as ready for review September 13, 2025 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub and Discord bots: Automate teammates invite to GitHub and Discord

1 participant