Estoy tratando de matar/acceder a un proceso. Debería iniciar otro bot y también poder matarlo. Esto es lo que he hecho.
const { Client, Intents, DiscordAPIError } = require("discord.js"); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS] }); const fs = require('fs'); const Discord = require (`discord.js`) const child = require (`child_process`) module.exports = { name: `start`, description: `start the bot`, execute(message, args){ child.exec(`node test.js`, (stderr, stdout) => { message.channel.send(`stderr: ${stderr}, stdout: ${stdout}`) }) } }Este es el comando donde quiero detener el bot.
const { Client, Intents, DiscordAPIError } = require("discord.js"); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS] }); const fs = require('fs'); const Discord = require (`discord.js`) const child = require (`child_process`) module.exports = { name: `stop`, description: `stop the bot`, execute(message, args){ //no idea what to put here }) } }¿Puedo obtener la identificación del proceso o guardar algo en una variable para acceder al proceso? Gracias por ayudar ;)
Esto terminará su programa
process.exit()