Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Client.chat is not a function #1359

Open
rafa-br34 opened this issue Dec 24, 2024 · 0 comments · May be fixed by #1355
Open

TypeError: Client.chat is not a function #1359

rafa-br34 opened this issue Dec 24, 2024 · 0 comments · May be fixed by #1355

Comments

@rafa-br34
Copy link

rafa-br34 commented Dec 24, 2024

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant