Skip to content

Conversation

@bryanchriswhite
Copy link
Contributor

Summary

This PR implements the Discord side of the RallyRound live speaker management system, addressing Issues #3-8. It enables Discord users to participate in structured meetings with speaker queues, hand-raising, parliamentary signals, and real-time synchronization with the RallyRound web dashboard.

Key Features:

  • Discord OAuth provider for cross-system authentication
  • Full RallyRound API client for session management
  • Native Discord slash commands (/rr) for all interactions
  • Voice channel presence tracking with automatic participant sync
  • Webhook receiver for RallyRound events
  • Sound effect playback in voice channels

Changes

1. Discord OAuth Provider (Issue #3)

  • GET /auth/discord - Initiates OAuth flow with CSRF protection
  • GET /auth/discord/callback - Exchanges code for JWT token (24h expiry)
  • GET /auth/validate - Validates tokens for RallyRound integration
  • GET /auth/user - Returns authenticated user profile

2. RallyRound API Client (Issue #4)

  • TypeScript client class with full type safety
  • Session CRUD, participant management, signals, speaker queue, agenda
  • Retry logic with exponential backoff for transient failures
  • Session registry to track active sessions per guild

3. Discord Slash Commands (Issue #5)

Native slash commands using @discordjs/builders:

Command Description
/rr start title:"..." Start a new session
/rr end, pause, resume Session lifecycle
/rr mode mode:structured Switch session mode
/rr record action:start Toggle recording indicator
/rr next, speaker user:@... Speaker management
/rr hand, point type:order Raise signals
/rr agree, disagree Sentiment signals
/rr agenda, agenda-add item:"..." Agenda management
/rr sfx action:on Sound effect controls

4. Voice Channel Presence Tracking (Issue #6)

  • Listens for voiceStateUpdate events
  • Auto-syncs participants when joining/leaving session VC
  • Bot joins voice channel when session starts
  • Graceful reconnection with exponential backoff

5. Webhook Receiver (Issue #7)

  • POST /webhooks/rallyround endpoint
  • HMAC-SHA256 signature verification
  • Timestamp validation (rejects webhooks > 5 minutes old)
  • Handles: signal_raised, speaker_changed, mode_changed, recording_changed, agenda_advanced, session_ended

6. Sound Effect Playback (Issue #8)

  • @discordjs/voice integration
  • Per-session audio players with queue management
  • Signal-to-sound mapping (hand → chime, point of order → gavel, etc.)
  • Prevents overlapping audio playback

New Dependencies

  • @discordjs/voice - Voice channel audio
  • jsonwebtoken - JWT signing/verification
  • drizzle-orm, better-sqlite3 - Database (ready for future use)

Environment Variables

DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_BOT_TOKEN=
JWT_SECRET=
RALLYROUND_API_URL=http://localhost:8765/api
RALLYROUND_URL=http://localhost:8765
WEBHOOK_BASE_URL=http://localhost:3002

Create detailed plan covering:
- Multi-Server Aggregation (Issues #1/#2)
- Discord OAuth Provider (Issue #3)
- RallyRound API Client (Issue #4)
- Bot Commands (Issue #5)
- Voice Channel Presence Tracking (Issue #6)
- Webhook Receiver (Issue #7)
- Sound Effect Playback (Issue #8)

Includes dependency graph, phased implementation order,
acceptance criteria, and technical specifications.
This commit implements the complete Discord side of the RallyRound
live speaker management system:

## Discord OAuth Provider (Issue #3)
- GET /auth/discord - Initiate OAuth flow with CSRF protection
- GET /auth/discord/callback - Exchange code for JWT token
- GET /auth/validate - Validate tokens for RallyRound
- GET /auth/user - Return authenticated user profile

## RallyRound API Client (Issue #4)
- Full TypeScript client for RallyRound session API
- Session, participant, signal, speaker, and agenda management
- Error handling with retry logic for transient failures
- Session registry to track active sessions per guild

## Bot Commands (Issue #5)
- !rr prefix command system with parser
- Session: start, end, pause, resume, status, link
- Mode: structured/unstructured, record start/stop
- Speaker: next, speaker @user, clear, queue
- Signals: hand, point order/clarify/info, question, agree/disagree
- Agenda: view, add, next, done, skip
- Sound effects: on/off, list, play specific sound

## Voice Channel Presence Tracking (Issue #6)
- Voice state event handler for join/leave/move
- Automatic participant sync with RallyRound API
- Bot joins voice channel when session starts
- isUserInSessionVC permission check

## Webhook Receiver (Issue #7)
- POST /webhooks/rallyround endpoint
- HMAC-SHA256 signature verification
- Timestamp validation (reject > 5 minutes old)
- Handlers for: signal_raised, speaker_changed, mode_changed,
  recording_changed, agenda_advanced, session_ended

## Sound Effect Playback (Issue #8)
- @discordjs/voice integration for audio playback
- Per-session audio players with queue management
- Signal-to-sound mapping
- Playback queue to prevent overlapping
Migrate from message-based prefix commands to Discord's native slash
command system using @discordjs/builders for better UX:

- Add /rr slash command with subcommands for all functionality
- Autocomplete, validation, and mobile-friendly interface
- No custom parser needed - Discord handles it

Slash command structure:
- /rr start title:"Session Name" - Start session
- /rr end, pause, resume, status, link - Session management
- /rr mode mode:structured|unstructured - Change mode
- /rr record action:start|stop - Recording control
- /rr next, speaker user:@alice, clear, queue - Speaker management
- /rr hand, point type:order|clarify|info, question - Signals
- /rr agree, disagree, away, back - Status signals
- /rr agenda, agenda-add, agenda-next, agenda-done - Agenda
- /rr sfx action:on|off|list, sfx-play sound:chime - Sound effects

Changes:
- Create definitions.ts with SlashCommandBuilder definition
- Create register.ts script to register commands with Discord
- Move handlers to handlers/ subdirectory for organization
- Update bot.ts to handle InteractionCreate instead of MessageCreate
- Add npm run register-commands script

Before using: Run `npm run register-commands` to register slash
commands with Discord (may take up to an hour to appear).
@bryanchriswhite bryanchriswhite self-assigned this Dec 26, 2025
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.

3 participants