H
H
heito2020-05-27 14:00:29
JavaScript
heito, 2020-05-27 14:00:29

How to run 2 or more bots on 1 server using mineflayer?

I checked they go to different servers, but they don’t write to the same one:

{ Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }

I tried to do like this:
const mineflayer = require('mineflayer');
const navigatePlugin = require('mineflayer-navigate')(mineflayer);
var vec3 = require('vec3');

var valera = mineflayer.createBot({
    host: "naxomoB.aternos.me",
    port: 25565,
    username: 'Valera',
    version: false
});
require(`./b.js`) // в b.js то же самое, но ник другой

So:
fs.readdir("./mcbots/", (err, files) => {

    if(err) console.log(err);
    let jsfile = files.filter(f => f.split(".").pop() === "js");
    if(jsfile.length <= 0){
        console.log("Add");
        return;
    }
      
    jsfile.forEach((f, i) =>{
        let props = require(`./mcbots/${f}`);
        console.log(`${f} loaded!`);
        props.run()
    });
});

And in these files was this:
const mineflayer = require('mineflayer');
const navigatePlugin = require('mineflayer-navigate')(mineflayer);
var vec3 = require('vec3');

module.exports.run = async (bot, message, args) => {
    var valera = mineflayer.createBot({
        host: "naxomoB.aternos.me",
        port: 25565,
        username: 'Valera',
        version: false
    });
    console.log('1')
}

module.exports.help = {
    name: "valera"
}

But nothing works, if you can tell me how to do it!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question