【发布时间】:2022-11-10 13:09:48
【问题描述】:
我正在尝试杀死/访问一个进程。它应该启动另一个机器人并且也能够杀死它。这是我所做的。
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}`)
})
}
}
这是我要停止机器人的命令。
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
})
}
}
我可以获取进程 ID 或将某些内容保存在变量中以访问进程吗? 感谢您的帮助;)
【问题讨论】:
标签: javascript node.js discord discord.js