bot.chat() isn't working #2842
Unanswered
D4rknezSl1me
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I didn't think. '1.19.2' was supported yet? EDIT: I used version 1.8.9 and successfully logged in and spawned no errors yet. still have you undefined bot.Socket.server / host as undefined still yet. use botSocket._host to get your host. I am sure you can use version 1.19 for your latest API uses un-tell version 1.19.2 is worked out.
…On Wed, Nov 23, 2022, 7:49 AM Christian Cangelli ***@***.***> wrote:
bot.chat() isn't working, i tried using await and not using it, it says
Cannot read properties of undefined.
here is my code and error log.
mineflayer = require('mineflayer');
let requirements = {
'host':'Enrico8401.aternos.me',
'port':'24712',
'version':'1.19.2'
};
class MCBot{
// Constructor
constructor(username){
this.username = username;
this.host = requirements['host'];
this.port = requirements['port'];
this.version = requirements['version'];
this.initBot()
};
// Init Bot Instance
initBot(){
this.bot = mineflayer.createBot({
'username': this.username,
'host': this.host,
'port': this.port,
'version': this.version
});
this.initEvents()
}
// Init Bot Events
initEvents(){
// Login Event
this.bot.on('login', ()=>{
let botSocket = this.bot._client.socket;
console.log(`[${this.username}] Logged in to ${botSocket.server ? botSocket.server : botSocket.host}`);
});
// Disconnect Event
this.bot.on('end', ()=>{
console.log(`[${this.username}] Disconnected`);
// Reconnection Attempt
setTimeout(()=> this.initBot, 2000);
});
// Error Event
this.bot.on('error', (err)=>{
if(err.code==='ECONNREFUSED'){
console.log(`[${this.username}] Failed to Reconnect to ${err.address}:${err.port}`);
}else{
console.log(`[${this.username}] Unhandled Error: ${err}`);
}
});
// Spawn Event
this.bot.on('spawn', async ()=>{
console.log(`[${this.username}] Spawned in`);
await this.bot.waitForTicks(0)
this.bot.chat(`${this.username}'s Ready!`);
/*
await this.bot.waitForTicks(60);
this.bot.chat("Goodbye!");
this.bot.quit();
*/
});
}
}
new MCBot("Bob")
// let bots = ["Bob"]
// for(var i = 0; i<bots.length; i++){
// bots.push(new MCBot(bots[i]))
// console.log("Bot added")
// }
This is the error
[Bob] Logged in to undefined
[Bob] Spawned in
TypeError: Serialization error for play.toServer : SizeOf error for undefined : Cannot read properties of undefined (reading 'length')
at Object.previousMessages (eval at compile (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\compiler.js:258:12), <anonymous>:175:37)
at Object.packet_chat_message (eval at compile (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\compiler.js:258:12), <anonymous>:599:37)
at eval (eval at compile (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\compiler.js:258:12), <anonymous>:1222:64)
at packet (eval at compile (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\compiler.js:258:12), <anonymous>:1270:9)
at CompiledProtodef.sizeOf (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\compiler.js:89:14)
at e.message (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\compiler.js:96:40)
at tryCatch (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\utils.js:50:16)
at CompiledProtodef.createPacketBuffer (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\compiler.js:96:20)
at Serializer.createPacketBuffer (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\serializer.js:12:23)
at Serializer._transform (C:\Users\xianc\Desktop\CHRIS\Minecraft\Bots\node_modules\protodef\src\serializer.js:18:18) {
field: 'play.toServer'
}
[Bob] Unhandled Error: TypeError: Serialization error for play.toServer : SizeOf error for undefined : Cannot read properties of undefined (reading 'length')
[Bob] Disconnected
—
Reply to this email directly, view it on GitHub
<#2842>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCUQLG5NTVLU4PUTMDEVXLWJY4JJANCNFSM6AAAAAASJDSUJE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
bot.chat() isn't working, i tried using await and not using it, it says Cannot read properties of undefined.
here is my code and error log.
This is the error
Beta Was this translation helpful? Give feedback.
All reactions