fix(informer): 🐛 add missing name for entity info when entity is a player

Uses `username` when `entity.name` is missing; should check other cases
This commit is contained in:
jay 2021-01-17 18:32:05 +05:00
parent 7cbfa16476
commit 7050a1621b

View File

@ -32,14 +32,15 @@ function item(
function entity(name) {
const entity = bot.nearestEntity((entity) => {
return name && entity.name ? entity.name == name : true
const ename = entity.name || entity.username
return name && ename ? ename == name : true
})
console.log(entity)
if (!entity) {
cfg.quiet || bot.chat("no entity")
return entity
}
let info = [entity.type, entity.name]
let info = [entity.type, entity.name || entity.username]
if (entity.metadata) info.push("len: " + entity.metadata.length)
cfg.quiet || bot.chat(info.join("; "))
}