feat: add a basic feature to rejoin on server restart

This commit is contained in:
jay
2020-12-24 13:38:16 +05:00
parent 0ae961521f
commit 086251bce6
2 changed files with 27 additions and 14 deletions

View File

@@ -46,7 +46,17 @@ const events = {
}
}
, chat: command
, kicked: (reason, loggedIn) => console.warn(reason, loggedIn)
, kicked: function rejoin(reason, loggedIn) {
console.warn(reason, loggedIn && "logged_in")
if (reason.extra && reason.extra[0].text === "Server closed") {
bot.quit()
bot.end()
// TODO implement all startup features (maybe refactor all into a single function / module?)
setTimeout((bot, cfg) => {
bot = mineflayer.createBot(cfg.botOptions)
}, 15 * 60 * 1000, bot, cfg);
}
}
}
const events_registered = []