I would like to create a command to start and stop my test Discord-Bot but have no idea on how to do a stop command. Maybe anyone can help me there? Here is my code.
if(args[0] === "start") {
child.exec("node test.js", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
}else {
if(args[0] === "stop") {
//stop the bot
}
}
Try .destroy() method, returns void.