import { client, startBot } from './bot/client.js';
import { db } from './database/db.js';
import { startWebServer } from './web/server.js';

const server = startWebServer();
await startBot();

function shutdown(signal: string) {
  console.log(`${signal} reçu, arrêt propre de VX BOT…`);
  server.close(() => {
    client.destroy();
    db.close();
    process.exit(0);
  });
}

process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT'));
