2022-08-15 18:57:26 -04:00
|
|
|
module.exports = client => {
|
|
|
|
client.nextMessage = (containing) => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
function onChat (packet) {
|
2023-01-21 14:31:17 -05:00
|
|
|
const m = packet.formattedMessage || packet.unsignedChatContent || JSON.stringify({ text: packet.plainMessage })
|
2022-08-15 18:57:26 -04:00
|
|
|
if (containing) {
|
|
|
|
if (m.includes(containing)) return finish(m)
|
|
|
|
else return
|
|
|
|
}
|
|
|
|
return finish(m)
|
|
|
|
}
|
2023-01-21 14:31:17 -05:00
|
|
|
client.on('playerChat', onChat)
|
|
|
|
client.on('systemChat', onChat) // For 1.7.10
|
2022-08-15 18:57:26 -04:00
|
|
|
|
|
|
|
function finish (m) {
|
2023-01-21 14:31:17 -05:00
|
|
|
client.off('playerChat', onChat)
|
|
|
|
client.off('systemChat', onChat)
|
2022-08-15 18:57:26 -04:00
|
|
|
resolve(m)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return client
|
|
|
|
}
|