FridayNightFunkinBoyfriendBot/src/modules/reconnect.js

19 lines
579 B
JavaScript
Raw Normal View History

2024-07-20 20:27:17 -04:00
const mc = require('minecraft-protocol');
const usernameGen = require("../util/usernameGen");
function reconnect (bot, options, config) {
2024-07-07 15:44:16 -04:00
bot.on('end', () => {
if (bot.reconnectDelay < 0) return
2024-07-20 20:27:17 -04:00
setTimeout(() => {
if (options.usernameGen) {
client = options.client ?? mc.createClient(options, bot.options.username = usernameGen(bot))
2024-07-20 20:27:17 -04:00
} else {
client = options.client ?? mc.createClient(options)
}
bot._client = client
bot.emit('init_client', bot._client)
}, options.reconnectDelay);
2024-07-07 15:44:16 -04:00
})
}
module.exports = reconnect;