()
| 63 | } |
| 64 | |
| 65 | private async initDatabase(): Promise<void> { |
| 66 | try { |
| 67 | const assetsDir = await createDirectoryInAssets("autodel"); |
| 68 | const dbPath = path.join(assetsDir, "autodel.db"); |
| 69 | |
| 70 | this.db = new Database(dbPath); |
| 71 | |
| 72 | this.db.exec(` |
| 73 | CREATE TABLE IF NOT EXISTS autodel_settings ( |
| 74 | chat_id TEXT PRIMARY KEY, |
| 75 | seconds INTEGER NOT NULL |
| 76 | ) |
| 77 | `); |
| 78 | |
| 79 | await this.loadExistingSettings(); |
| 80 | } catch (error) { |
| 81 | console.error("Failed to initialize autodel database:", error); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | private async loadExistingSettings(): Promise<void> { |
| 86 | if (!this.db) return; |
no test coverage detected