const { spawn: s } = require("child_process"); const fs = require("fs"); const l = require("./utils/log"); const moment = require('moment-timezone'); const file = './utils/check.json'; if (!fs.existsSync(file)) fs.writeFileSync(file, JSON.stringify({})); const time = () => { const ctime = moment().tz('Asia/Ho_Chi_Minh').format('YYYY-MM-DD HH:mm:ss'); fs.writeFileSync(file, JSON.stringify({ datetime: ctime })); }; setInterval(time, 30 * 1000); const sr = () => { l('🌸 ĐANG KHỞI ĐỘNG BOT', "⟦ KÍCH HOẠT ⟧⪼ "); const c = s("node", ["--trace-warnings", "--async-stack-traces", "mirai.js"], { cwd: __dirname, stdio: "inherit", shell: true }); c.on("close", async (e) => { if (e == 1) return sr("🔄 BOT ĐANG KHỞI ĐỘNG LẠI!!!"); else if (String(e).startsWith("2")) { await new Promise((r) => setTimeout(r, parseInt(e.replace('2', '')) * 1000)); sr("🌸 BOT ĐÃ ĐƯỢC KÍCH HOẠT, VUI LÒNG CHỜ MỘT CHÚT!!!"); } }); c.on("error", (error) => l("Đã xảy ra lỗi: " + JSON.stringify(error), "[ Khởi động ]")); }; sr();