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
}
}
CodePudding user response:
I'm not sure to understand what you want. But if you have a Discord-Bot you need to host it somewhere. So if your bot is unactive it can't wait for a keyword.
If the idea it's just to have access to commands of your bot depending of on/off you can do this with a simple boolean.
CodePudding user response:
Try .destroy()
method, returns void
.