我正在用Electron为不和谐的机器人制作一个UI,这样我可以更好地对其进行管理,并且因为它始终保持打开状态,所以我无法关闭它。
function myFunction2() {
var x = document.getElementById("connect");
if (x.innerHTML === "turn on") {
x.innerHTML = "turn off";
document.getElementById("2").style.backgroundColor = "green";
bot.on('ready', () => {
log(`Logged in as ${bot.username} - ${bot.id}\n`);
});
bot.on('message', (username, userID, channelID, message, event) => {
log({
username,
userID,
channelID,
message
});
const matches = message.match(/(ぽ|ポ|po)/i);
if (!matches) return;
const po = matches[1];
bot.sendMessage({
to: channelID,
message: `${po}だよ`
});
})
} else {
x.innerHTML = "turn on";
document.getElementById("2").style.backgroundColor = "red";
bot.destroy()
myFunction2().destroy()
}
}
它应该关闭机器人,但保持打开状态。没有错误消息。