✅ **MAJOR MILESTONE**: Bot successfully starts and loads all commands 🔧 **Key Fixes Applied**: - Fixed Pydantic configuration (SettingsConfigDict vs ConfigDict) - Resolved duplicate logging with hybrid propagation approach - Enhanced console logging with detailed format (function:line) - Eliminated redundant .log file handler (kept console + JSON) - Fixed Pylance type errors across views and modals - Added newline termination to JSON logs for better tool compatibility - Enabled league commands package in bot.py - Enhanced command tree hashing for proper type support 📦 **New Components Added**: - Complete views package (base.py, common.py, embeds.py, modals.py) - League service and commands integration - Comprehensive test coverage improvements - Enhanced decorator functionality with proper signature preservation 🎯 **Architecture Improvements**: - Hybrid logging: detailed console for dev + structured JSON for monitoring - Type-safe command tree handling for future extensibility - Proper optional parameter handling in Pydantic models - Eliminated duplicate log messages while preserving third-party library logs 🚀 **Ready for Production**: Bot loads all command packages successfully with no errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
"""
|
|
Configuration management for Discord Bot v2.0
|
|
"""
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class BotConfig(BaseSettings):
|
|
"""Application configuration with environment variable support."""
|
|
|
|
# Discord settings
|
|
bot_token: str
|
|
guild_id: int
|
|
|
|
# Database API settings
|
|
api_token: str
|
|
db_url: str
|
|
|
|
# League settings
|
|
sba_season: int = 12
|
|
pd_season: int = 9
|
|
fa_lock_week: int = 14
|
|
sba_color: str = "a6ce39"
|
|
|
|
# Application settings
|
|
log_level: str = "INFO"
|
|
environment: str = "development"
|
|
testing: bool = False
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
case_sensitive=False,
|
|
extra="ignore" # Ignore extra environment variables
|
|
)
|
|
|
|
@property
|
|
def is_development(self) -> bool:
|
|
"""Check if running in development mode."""
|
|
return self.environment.lower() == "development"
|
|
|
|
@property
|
|
def is_testing(self) -> bool:
|
|
"""Check if running in test mode."""
|
|
return self.testing
|
|
|
|
|
|
# Global configuration instance - lazily initialized to avoid import-time errors
|
|
_config = None
|
|
|
|
def get_config() -> BotConfig:
|
|
"""Get the global configuration instance."""
|
|
global _config
|
|
if _config is None:
|
|
_config = BotConfig() # type: ignore
|
|
return _config |