| 296 | const transaction = db.transaction(() => { |
| 297 | // Delete participants |
| 298 | const deleteParticipants = db.prepare(`DELETE FROM lottery_participants WHERE lottery_id = ?`); |
| 299 | deleteParticipants.run(lotteryId); |
| 300 | |
| 301 | // Delete winners |
| 302 | const deleteWinners = db.prepare(`DELETE FROM lottery_winners WHERE lottery_id = ?`); |
| 303 | deleteWinners.run(lotteryId); |
| 304 | |
| 305 | // Delete lottery config |
| 306 | const deleteLottery = db.prepare(`DELETE FROM lottery_config WHERE id = ?`); |
| 307 | deleteLottery.run(lotteryId); |
| 308 | }); |
| 309 | |
| 310 | transaction(); |
| 311 | return true; |
| 312 | } catch (error) { |
| 313 | console.error("Failed to delete lottery activity:", error); |
| 314 | return false; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | // Enhanced lottery management functions |
| 319 | function createLotteryConfig(config: any): number { |
| 320 | if (!db) return 0; |
| 321 | |
| 322 | const stmt = db.prepare(` |
| 323 | INSERT INTO lottery_config ( |
| 324 | chat_id, title, keyword, max_participants, winner_count, mode, |
| 325 | distribution_mode, claim_timeout, delete_delay, require_avatar, |
| 326 | require_username, required_channel, prize_warehouse, allow_bots, |