question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

  • What you want to do (the objective in English): I’m trying to make it so both of my accounts/bots will run /server [realm] at login.
  • What you tried (the code):
var bot = mineflayer.createBot({ 
  host: ServerIP,
  port: ServerPort,
  username: MinecraftEmail1,
  password: MinecraftPassword1,
  version: "1.8"
});

var bot = mineflayer.createBot({ 
  host: ServerIP,
  port: ServerPort,
  username: MinecraftEmail2,
  password: MinecraftPassword2,
  version: "1.8"
});

bot.on('login', function() {
  bot.chat("/server [realm]");
  console.log("Succesfully logged in at " + ServerName);
});
  • What happened: Only one of the bots used /server realm upon login. The other bot stayed in the hub.

  • What you expected to happen: I expected them both to join the realm.

Yes, both of the bots logged into the server but only one of them joined the realm. I was using mineflayer 2.7.5 when getting this issue.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
wvfflecommented, Apr 29, 2019

Here. That should work for you Remember to define ServerIP, ServerPort and ServerName Also to login in offline mode pass undefined as password. NOT 'undefined' NOR "undefined". Simply undefined without quotes

const credentials = [
  { username: 'mineflayer-bot-1', password: 'x' },
  { username: 'mineflayer-bot-2', password: 'x' },
]

const bots = []
for (let i = 0; i < credentials.length; ++i) {
  setTimeout(() => {
    createBot(credentials[i])
    if (i === credentials.length) ready()
  }, i * 100)
}

function createBot ({ username, password }) {
  const bot = mineflayer.createBot({
    host: ServerIP,
    port: ServerPort,
    username,
    password,
    version: "1.8"
  })

  bots.push(bot)
}

function ready () {
  // Here goes your code
  // To access bot use bots[index] where index is number from 0 to credentials.length
  bots[0].on('forcedMove', function() {
    bots[0].chat("I'm being teleported")
  })

  // To do something with EVERY bot do it like that:
  bots.forEach(bot => {
    bot.on('login', function() {
      bot.chat("/server realm");
      console.log("Succesfully logged in at " + ServerName)
    })
  })
}
0reactions
rom1504commented, May 4, 2019

fixed in other issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 Elements of a Multi-Bot Architecture to Overcome NLP and ...
A Multi-bot Approach to Conversational AI helps enterprises build more consistent conversational experiences that can scale easily across the business.
Read more >
Multiple Bots - Automation Anywhere aPeople
How to pass control between multiple bots so that processing is real time rather than waiting for the scheduler? We have three bots...
Read more >
Run Multiple Bots - Hummingbot Docs
Users can run multiple bots of Hummingbot installed via binary by simply running a new instance to open a new window. Multiple bots...
Read more >
Multiple bots? : r/TheTowerGame - Reddit
Multiple bots ? Anyone know if you can have more than 1 active bot? I almost have enough to unlock a second bot....
Read more >
The Power of Reusable Automations Across Multiple Bots
Save time. Scale quickly and efficiently with reusable automations. Learn how to use an automation across multiple bots.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found