CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/examples/repl.js
Views: 789
1
const mineflayer = require('mineflayer')
2
const repl = require('repl')
3
4
if (process.argv.length < 4 || process.argv.length > 6) {
5
console.log('Usage : node repl.js <host> <port> [<name>] [<password>]')
6
process.exit(1)
7
}
8
9
const bot = mineflayer.createBot({
10
host: process.argv[2],
11
port: parseInt(process.argv[3]),
12
username: process.argv[4] ? process.argv[4] : 'repl',
13
password: process.argv[5]
14
})
15
16
bot.on('login', () => {
17
const r = repl.start('> ')
18
r.context.bot = bot
19
20
r.on('exit', () => {
21
bot.end()
22
})
23
})
24
25