Run clearInterval when reconnecting

This commit is contained in:
7cc5c4f330d47060 2024-07-17 08:23:06 -04:00
parent b25aad71a1
commit e48ce14155
2 changed files with 5 additions and 2 deletions

View file

@ -48,7 +48,10 @@ const createBot = function createBot(host,oldId){
//console.log(bot);
})
if(typeof oldId !== "undefined"){
delete bot[oldId];
for(const i in module.exports.bot[oldId].interval){
clearInterval(module.exports.bot[oldId].interval[i]);
}
delete module.exports.bot[oldId];
bot.id=oldId;
module.exports.bot[oldId]=bot;
console.log("Re-creating bot "+bot.id)

View file

@ -57,7 +57,7 @@ module.exports = {
b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`)
})
b.on('ccstart', () => {
setTimeout(() => { b.ccqi = setInterval(b.advanceccq, 12) }, 1000) // 1 Second and 12 Milliseconds
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 12) }, 1000) // 1 Second and 12 Milliseconds
b.ccStarted = true;
b.info("Command block!");
})