mineflayer icon indicating copy to clipboard operation
mineflayer copied to clipboard

How to respawn bot?

Open FurnyGo opened this issue 2 years ago • 2 comments

Sometimes, when my bot is killed, it can't respawn and sends to the logs "Cannot send chat message". Maybe there is a way to respawn it?

FurnyGo avatar Oct 15 '22 07:10 FurnyGo

The bot should auto respawn, if it's not doing that, maybe there's something blocking the process and slowing down the bot, what's your code?

amoraschi avatar Oct 15 '22 08:10 amoraschi

   await bot.once('spawn', ()=> {
       bot.chat("/login "+pass);
       setTimeout(() => {
           bot.chat('/servers');
       }, 400);
   });
   var slot = 12;
   await bot.on('windowOpen', (window) => {
       bot.clickWindow(slot, 1, 0);
       bot.closeWindow(window)
   });
   bot.on('death', ()=> {
       setTimeout(() => {
           bot.chat('/warp testwarp')
       }, 300);
   })
   bot.on('messagestr', (message, messagePosition, jsonMsg)=> {
       if (message.includes("Welcome!")){
           setTimeout(() => {
                   setTimeout(() => {
                       bot.chat('/warp testwarp')
                   }, 150);
           }, 400);
       }
       } 
   })
   bot.on('error', (err)=> {
       bot.quit()
   })
}

And it can't respawn after rejoin

FurnyGo avatar Oct 15 '22 10:10 FurnyGo

the thing ur doing wrong is bot.on('death', ()=> { setTimeout(() => { bot.chat('/warp testwarp') }, 300); }) bot.on('death') should respawn the bot but it types the chat in the respawn screen causing the bot to stay stuck on that screen try using bot.on('spawn', ()=> {bot.chat('/warp testwarp')}) and on the top u declared that on spawn the bot does the authentication which should be done on bot.on('login') and a main thing dont use bot.once whenever the bot spawns instead use bot.on('spawn') its better u can use bot.once() when u want to login

MrFiend179 avatar Oct 21 '22 15:10 MrFiend179

Try removing the /warp on respawn event and see if it works correctly

extremeheat avatar Oct 22 '22 22:10 extremeheat