()
| 45 | } |
| 46 | |
| 47 | async start() { |
| 48 | try { |
| 49 | startupLog('Starting TitanBot...'); |
| 50 | await new Promise(resolve => setTimeout(resolve, 1000)); |
| 51 | |
| 52 | startupLog('Initializing database...'); |
| 53 | const dbInstance = await initializeDatabase(); |
| 54 | this.db = dbInstance.db; |
| 55 | |
| 56 | // Check database status and report |
| 57 | const dbStatus = this.db.getStatus(); |
| 58 | if (dbStatus.isDegraded) { |
| 59 | logger.warn(''); |
| 60 | logger.warn('╔═══════════════════════════════════════════════════════╗'); |
| 61 | logger.warn('║ ⚠️ DATABASE RUNNING IN DEGRADED MODE ║'); |
| 62 | logger.warn('║ ║'); |
| 63 | logger.warn('║ Connection: In-Memory Storage (PostgreSQL unavailable)║'); |
| 64 | logger.warn('║ Data Persistence: DISABLED - data lost on restart ║'); |
| 65 | logger.warn('║ Action Required: Fix PostgreSQL and restart bot ║'); |
| 66 | logger.warn('╚═══════════════════════════════════════════════════════╝'); |
| 67 | logger.warn(''); |
| 68 | } else { |
| 69 | startupLog(`✅ Database Status: ${dbStatus.connectionType} (fully operational)`); |
| 70 | } |
| 71 | |
| 72 | startupLog('Starting web server...'); |
| 73 | this.startWebServer(); |
| 74 | |
| 75 | startupLog('Loading commands...'); |
| 76 | await loadCommands(this); |
| 77 | startupLog(`Commands loaded: ${this.commands.size}`); |
| 78 | |
| 79 | startupLog('Loading handlers...'); |
| 80 | await this.loadHandlers(); |
| 81 | startupLog('Handlers loaded'); |
| 82 | |
| 83 | startupLog('Logging into Discord...'); |
| 84 | await this.login(this.config.bot.token); |
| 85 | startupLog('Discord login successful'); |
| 86 | |
| 87 | startupLog('Registering slash commands...'); |
| 88 | await this.registerCommands(); |
| 89 | if (this.config.bot.multiGuild) { |
| 90 | startupLog('Multi-guild mode enabled — slash commands registered globally'); |
| 91 | } else if (this.config.bot.guildId) { |
| 92 | startupLog(`Single-guild mode — slash commands registered for guild ${this.config.bot.guildId}`); |
| 93 | } |
| 94 | startupLog('Slash commands registration complete'); |
| 95 | |
| 96 | const databaseMode = dbStatus.isDegraded |
| 97 | ? 'Optional in-memory mode (data resets after restart)' |
| 98 | : 'Connected (persistent data enabled)'; |
| 99 | const handlerSummary = `${this.buttons.size} buttons, ${this.selectMenus.size} menus, ${this.modals.size} modals`; |
| 100 | startupLog( |
| 101 | `ONLINE ✅ | ${this.commands.size} commands loaded | ${handlerSummary} | Database: ${databaseMode}` |
| 102 | ); |
| 103 | |
| 104 | this.setupCronJobs(); |
no test coverage detected