20 lines
664 B
JavaScript
20 lines
664 B
JavaScript
console.log("Starting bot...");
|
|
var botInstance = require("child_process").fork("bot.js");
|
|
var a = async (message) => {
|
|
if (message == "restart"){
|
|
console.log("Restart requested.");
|
|
console.log("Killing bot...");
|
|
await botInstance.kill();
|
|
console.log("Starting bot...");
|
|
botInstance = await require("child_process").fork("bot.js");
|
|
botInstance.on("message", a)
|
|
}
|
|
}
|
|
botInstance.on("exit", async (code) => {
|
|
if (code != 0){
|
|
console.log("Bot crashed...");
|
|
botInstance = await require("child_process").fork("bot.js");
|
|
botInstance.on("message", a)
|
|
}
|
|
})
|
|
botInstance.on("message", a) |