PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.92k stars 904 forks source link

Mineflayer Not Reporting All Chat Messages #2147

Closed ghost closed 3 years ago

ghost commented 3 years ago

Versions

Detailed description of a problem

A clear and concise description of what the problem is, with as much context as possible. What are you building? What problem are you trying to solve? I am trying to create a bot on Hypixel housing that reads chat messages, but I am having an issue where it doesn't pick up the death messages. I have tried the events "Message", "Chat", "MessageStr", "Whisper" but seem to have no luck. I can get the join and leave messages, chat + everything else, but it seems like the death messages don't work.

What did you try yet?

Did you try any method from the API? "Message", "Chat", "MessageStr", "Whisper" Did you try any example? Any error from those? No errors. Just doesn't log the messages.

Your current code


/*
bot.on('chat', async (username, message) => {
  console.log(message)
})

bot.on('message', (message) => {
  console.log(message.text)
})

bot.on('messagestr', (message) => {
  console.log(message.text)
})

bot.on('whisper', (message) => {
  console.log(message.text)
})
*/

Expected behavior

A clear and concise description of what you expected to happen. It should log the death message, eg: User was killed by User1.

Additional context

Add any other context about the problem here.

u9g commented 3 years ago

message.text is not what you think it is (look at Prismarine-Chat for more info), use bot.on('messagestr', msg => console.log(msg.toString())