PrismarineJS / mineflayer

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

how i can see chat clickevent #1227

Closed fhjkregjlkhgjhre closed 4 years ago

fhjkregjlkhgjhre commented 4 years ago

Versions

Detailed description of a question

How i can see what is on the clickevent (like commands and urls)

IdanHo commented 4 years ago
msg.clickEvent.action
fhjkregjlkhgjhre commented 4 years ago
msg.clickEvent.action

ty

wvffle commented 4 years ago

Is there a reason you've just reopened the issue?

fhjkregjlkhgjhre commented 4 years ago

Is there a reason you've just reopened the issue?

im testing and i hit the wrong button :/

fhjkregjlkhgjhre commented 4 years ago
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)
fhjkregjlkhgjhre commented 4 years ago

i guess i need to do this msg.json.clickevent.action?

IdanHo commented 4 years ago

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.

fhjkregjlkhgjhre commented 4 years ago

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

wvffle commented 4 years ago

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

fhjkregjlkhgjhre commented 4 years ago

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

ok

fhjkregjlkhgjhre commented 4 years ago

i guess thats all ty for the help