Fix chat echo sample (#233)
* Fix chat echo sample The `client.options.username` reference is optional for online connections. Referencing it here when it is null will not filter out the echo text, causing an infinite loop. * Update client.js
This commit is contained in:
parent
149b4fe182
commit
7263714562
2 changed files with 3 additions and 3 deletions
|
|
@ -50,7 +50,7 @@ const client = bedrock.createClient({
|
|||
})
|
||||
|
||||
client.on('text', (packet) => { // Listen for chat messages and echo them back.
|
||||
if (packet.source_name != client.options.username) {
|
||||
if (packet.source_name != client.username) {
|
||||
client.queue('text', {
|
||||
type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
|
||||
message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}`
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ const client = bedrock.createClient({
|
|||
})
|
||||
|
||||
client.on('text', (packet) => { // Listen for chat messages and echo them back.
|
||||
if (packet.source_name != client.options.username) {
|
||||
if (packet.source_name != client.username) {
|
||||
client.queue('text', {
|
||||
type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
|
||||
message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}`
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue