Closed nikitapro225 closed 2 months ago
This is a problem with your code. The specific error is being triggered in followPlayer if you read the stack trace. this
should only be directly used in class instance methods (creating a new function creates a new this
scope which is outside the class instance scope). I'd recommend learning a bit more JS before working on a mineflayer bot and asking ChatGPT to rewrite your code to fix this error.
`const mineflayer = require('mineflayer'); const { pathfinder, Movements, goals } = require('mineflayer-pathfinder') const GoalFollow = goals.GoalFollow const GoalBlock = goals.GoalBlock
let botArgs = { host: '94.198.54.132', port: 38744, version: '1.16.5' };
class MCBot {
}
let bots = []; for(var i = 0; i < 10; i++) { bots.push(new MCBot(
RAB${i}
)) bots.push(new MCBot(RAB${i}
)) }`C:\Users\Vova\node_modules\minecraft-protocol\src\transforms\framing.js:67 } else { throw e } ^
TypeError: Cannot read properties of undefined (reading 'bot') at followPlayer (C:\Users\Vova\Desktop\bot nikita\mimn.js:58:35) at EventEmitter. (C:\Users\Vova\Desktop\bot nikita\mimn.js:107:21)
at EventEmitter.emit (node:events:531:35)
at EventEmitter. (C:\Users\Vova\node_modules\mineflayer\lib\plugins\chat.js:85:13)
at EventEmitter.emit (node:events:519:28)
at Client. (C:\Users\Vova\node_modules\mineflayer\lib\plugins\chat.js:130:9)
at Client.emit (node:events:519:28)
at Client. (C:\Users\Vova\node_modules\minecraft-protocol\src\client\play.js:73:18)
at Client.emit (node:events:519:28)
at emitPacket (C:\Users\Vova\node_modules\minecraft-protocol\src\client.js:83:12)
Node.js v21.7.1
Bot crash when i input -bot follow