Add comprehensive voice channel system for Discord gameplay with:
## New Features
- `/voice-channel public` - Create public voice channels with random codenames
- `/voice-channel private` - Create private team vs team channels with role permissions
- Automatic cleanup after configurable empty duration (default: 5 minutes)
- Restart-resilient JSON persistence for channel tracking
- Background monitoring service with graceful error handling
## Technical Implementation
- **Voice Commands Package** (`commands/voice/`)
- `channels.py` - Main slash command implementation with modern command groups
- `cleanup_service.py` - Background service for automatic channel deletion
- `tracker.py` - JSON-based persistent channel tracking
- `__init__.py` - Package setup with resilient loading
- **Bot Integration** - Voice cleanup service integrated into bot lifecycle
- **Service Dependencies** - Integration with team, league, and schedule services
- **Permission System** - Team-based Discord role permissions for private channels
## Key Features
- **Public Channels**: Random codenames, open speaking permissions
- **Private Channels**: "{Away} vs {Home}" naming, team role restrictions
- **Auto-cleanup**: Configurable intervals with empty duration thresholds
- **Restart Resilience**: JSON file persistence survives bot restarts
- **Error Handling**: Comprehensive validation and graceful degradation
- **Migration Support**: Deprecated old prefix commands with helpful messages
## Documentation & Testing
- Comprehensive README.md following project patterns
- Full test suite with 15+ test methods covering all scenarios
- Updated CLAUDE.md files with voice command documentation
- Clean IDE diagnostics with proper type safety
## Integration Points
- Team service for user validation and role lookup
- League service for current season/week information
- Schedule service for opponent detection in private channels
- Background task management in bot startup/shutdown
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
"""
|
|
Voice Commands Package
|
|
|
|
This package contains voice channel management commands for gameplay.
|
|
"""
|
|
import logging
|
|
from discord.ext import commands
|
|
|
|
from .channels import VoiceChannelCommands
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def setup_voice(bot: commands.Bot):
|
|
"""
|
|
Setup all voice command modules.
|
|
|
|
Returns:
|
|
tuple: (successful_count, failed_count, failed_modules)
|
|
"""
|
|
# Define all voice command cogs to load
|
|
voice_cogs = [
|
|
("VoiceChannelCommands", VoiceChannelCommands),
|
|
]
|
|
|
|
successful = 0
|
|
failed = 0
|
|
failed_modules = []
|
|
|
|
for cog_name, cog_class in voice_cogs:
|
|
try:
|
|
await bot.add_cog(cog_class(bot))
|
|
logger.info(f"✅ Loaded {cog_name}")
|
|
successful += 1
|
|
except Exception as e:
|
|
logger.error(f"❌ Failed to load {cog_name}: {e}", exc_info=True)
|
|
failed += 1
|
|
failed_modules.append(cog_name)
|
|
|
|
# Log summary
|
|
if failed == 0:
|
|
logger.info(f"🎉 All {successful} voice command modules loaded successfully")
|
|
else:
|
|
logger.warning(f"⚠️ Voice commands loaded with issues: {successful} successful, {failed} failed")
|
|
|
|
return successful, failed, failed_modules
|
|
|
|
|
|
# Export the setup function for easy importing
|
|
__all__ = ['setup_voice', 'VoiceChannelCommands'] |