node-minecraft-protocol
node-minecraft-protocol copied to clipboard
TypeError: Client.chat is not a function
[x] The FAQ doesn't contain a resolution to my issue
Versions
- minecraft-protocol: 1.20.1 (Protocol: 763)
- server: Vanilla
- node: v22.12.0
Client.chat is only initialized after playerJoin is triggered.
The playerJoin event signals that the client is ready to send packets and interact with the API, however, the onReady function at /src/client/play.js@L68 only sets client.chat after the playerJoin event has been fired.
Current code
let Player = "[redacted]"
let Host = "[redacted]"
let Port = [redacted]
console.log(`> ${Player}`)
let Client = Minecraft.createClient({
host: Host,
port: Port,
username: Player
})
Client.on("state", State => console.log(State))
Client.on("playerJoin", () => {
Client.chat(`/tell ${Player} TypeError...`)
})
await new Promise((Resolve, _Reject) => {
Client.once("end", Resolve)
})
console.log(`< ${Player}`)
Expected behavior
For Client.chat to be ready when playerJoin is fired.