Spaces:
Paused
Paused
File size: 638 Bytes
387a0b8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | const { spawn } = require("child_process");
const botFiles = [
"spotify.js"
];
function startBot(file) {
console.log(`Starting bot: ${file}`);
const child = spawn("node", ["--trace-warnings", "--async-stack-traces", file], {
cwd: __dirname,
stdio: "inherit",
shell: true,
});
child.on("close", (codeExit) => {
console.log(`Bot process (${file}) exited with code: ${codeExit}`);
if (codeExit !== 0) {
setTimeout(() => startBot(file), 3000);
}
});
child.on("error", (error) => {
console.error(`An error occurred starting the bot (${file}): ${error}`);
});
}
botFiles.forEach(startBot); |