Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. var mineflayer = require('mineflayer');
  2. const Vec3 = require('vec3').Vec3
  3. var readline = require("readline");
  4.  
  5. var rl = readline.createInterface({
  6. input: process.stdin,
  7. output: process.stdout
  8. });
  9.  
  10. if (process.argv.length < 4 || process.argv.length > 6) {
  11. console.log('Usage : node melonBot.js <host> <port> [<name>] [<password>]')
  12. process.exit(1)
  13. }
  14.  
  15. const bot = mineflayer.createBot({
  16. host: process.argv[2],
  17. port: parseInt(process.argv[3]),
  18. username: process.argv[4] ? process.argv[4] : 'melonBot',
  19. password: process.argv[5],
  20. verbose: true
  21. });
  22.  
  23. bot.on('login', () => {
  24. bot.chat('Hi everyone! I am MelonBot, created by MelendoFX!')
  25. rl.on('line', function (consolecmd) {
  26. if (consolecmd.startsWith('say ')){
  27. bot.chat(consolecmd.substring(4))
  28. console.log("Message sent ingame.")
  29. }
  30. rl.prompt()
  31. });
  32. bot.on('chat', function(username, message) {
  33. chatEvent(username, message)
  34. });
  35. bot.on('kicked', (reason) => {
  36. console.log('I got kicked for ${reason}')
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement