-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 740 Bytes
/
index.js
File metadata and controls
29 lines (23 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const mineflayer = require('mineflayer')
function startBot() {
const bot = mineflayer.createBot({
host: process.env.MC_SERVER,
port: process.env.MC_PORT || 25565,
username: process.env.MC_EMAIL,
auth: "microsoft"
})
bot.on('login', () => {
console.log(`Bot logged in as ${bot.username}`)
})
bot.on('end', () => {
console.log(`Bot disconnected. Reconnecting in ${process.env.RECONNECT_INTERVAL || 5000}ms...`)
setTimeout(startBot, parseInt(process.env.RECONNECT_INTERVAL || 5000))
})
bot.on('kicked', (reason) => {
console.log(`Kicked: ${reason}`)
})
bot.on('error', (err) => {
console.log(`Error: ${err}`)
})
}
startBot()