Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS
GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/examples/quitter.js
9427 views
1
/*
2
* This is one of the simplest examples.
3
*
4
* We created a simple bot that connects to a server and immediately quits.
5
*
6
* It's not very useful yet, but you can use this as a starting point
7
* to create your own bot.
8
*/
9
const mineflayer = require('mineflayer')
10
11
if (process.argv.length < 4 || process.argv.length > 6) {
12
console.log('Usage : node quitter.js <host> <port> [<name>] [<password>]')
13
process.exit(1)
14
}
15
16
const bot = mineflayer.createBot({
17
host: process.argv[2],
18
port: parseInt(process.argv[3]),
19
username: process.argv[4] ? process.argv[4] : 'emobot',
20
password: process.argv[5]
21
})
22
23
bot.once('spawn', () => {
24
bot.chat('Goodbye, cruel world!')
25
bot.quit()
26
})
27
28