#ChatSend | targets is undefined

1 messages · Page 1 of 1 (latest)

arctic blaze
#
import {system, world} from "@minecraft/server"

world.beforeEvents.chatSend.subscribe((event)=>{
    const {message, sender, targets} = event
    const msg = message.toLowerCase()
    if(!msg.startsWith("!replay")) return
    event.cancel = true
    const participant = targets?[sender, ...targets]:[sender]
    participant.forEach((p)=>{
        console.warn(p.name , targets);
        p.sendMessage("test message | §c" + sender.name + "§r invited you to a replay session")
    })
    
})

when sending !replay @anotherPlayer
the other player never receive the message. isn't that what targets property for?
tried /whisperer @anotherPlayer and didn't work also. am i doing something wrong or what?

#

uhh nvm

gritty lion
#

Is target still in beta?

arctic blaze
gritty lion
#

Target...

arctic blaze
gritty lion
#

From chatsend

arctic blaze
#

you mean targets?

gritty lion
#

Yeah

arctic blaze
#

isn't the event it self beta?

arctic blaze
# arctic blaze uhh nvm

it doesn't contain players mentioned in the message
it is a set property
the message will be sent only to the players in the list if specified

world.beforeEvents.chatSend.subscribe((event)=>{
    event.targets = world.getAllPlayers().filter(p=> p.hasTag("allowChat"))
})

in this example only players with the tag receive the message

gritty lion
#

I have no clue when that property would ever be defined

#

Broadcast thing prob, dunno