Я создаю пользовательский интерфейс в Electron для своего диссон-бота, чтобы я мог лучше им управлять и вообще не могу выключить бот, поскольку он всегда остается включенным.
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()
}
}
Он должен выключить бота, но остается включенным. Нет сообщения об ошибке.