Closed fhjkregjlkhgjhre closed 4 years ago
msg.clickEvent.action
msg.clickEvent.action
ty
Is there a reason you've just reopened the issue?
Is there a reason you've just reopened the issue?
im testing and i hit the wrong button :/
msg.clickEvent.action
and this didnt work gives me this error
ERRO -> TypeError: Cannot read property 'action' of undefined
2020-08-09T20:06:38.469172+00:00 app[worker.1]: at Bot.<anonymous> (/app/main.js:49:33)
2020-08-09T20:06:38.469172+00:00 app[worker.1]: at Bot.emit (events.js:315:20)
2020-08-09T20:06:38.469174+00:00 app[worker.1]: at Client.<anonymous> (/app/node_modules/mineflayer/lib/plugins/chat.js:69:9)
2020-08-09T20:06:38.469174+00:00 app[worker.1]: at Client.emit (events.js:315:20)
2020-08-09T20:06:38.469174+00:00 app[worker.1]: at FullPacketParser.<anonymous> (/app/node_modules/minecraft-protocol/src/client.js:89:12)
2020-08-09T20:06:38.469175+00:00 app[worker.1]: at FullPacketParser.emit (events.js:315:20)
2020-08-09T20:06:38.469175+00:00 app[worker.1]: at addChunk (/app/node_modules/readable-stream/lib/_stream_readable.js:298:12)
2020-08-09T20:06:38.469175+00:00 app[worker.1]: at readableAddChunk (/app/node_modules/readable-stream/lib/_stream_readable.js:280:11)
2020-08-09T20:06:38.469176+00:00 app[worker.1]: at FullPacketParser.Readable.push (/app/node_modules/readable-stream/lib/_stream_readable.js:241:10)
i guess i need to do this msg.json.clickevent.action
?
that means that message doesnt have a clickEvent, you have to check first if it does via
if (msg.clickEvent) { }
prismarine-chat parses the json itself, you dont have to access it directly.
that means that message doesnt have a clickEvent, you have to check first if it does via
if (msg.clickEvent) { }
prismarine-chat parses the json itself, you dont have to access it directly.
ok
If you want to access raw messages then you can use some low level stuff:
bot._client.on('chat', (packet) => {
const msg = JSON.parse(packet.message)
// msg is now a raw json message
})
Edit: Also, if you have a parsed ChatMessage
instance (from message
or chat
events), you can use msg.json
to access the raw json message
If you want to access raw messages then you can use some low level stuff:
bot._client.on('chat', (packet) => { const msg = JSON.parse(packet.message) // msg is now a raw json message })
Edit: Also, if you have a parsed
ChatMessage
instance (frommessage
orchat
events), you can usemsg.json
to access the raw json message
ok
i guess thats all ty for the help
Versions
Detailed description of a question
How i can see what is on the clickevent (like commands and urls)