feat(informer): 🚸 make entity search case insensitive

This commit is contained in:
jay 2021-05-11 17:32:38 +05:00
parent 69b1ab0b0b
commit 3379f75ab9

View File

@ -116,12 +116,12 @@ function item(
return item return item
} }
function entity(name) { function entity(name = bot.nearestEntity()) {
const entity = typeof name === "string" ? bot.nearestEntity((entity) => { const entity = typeof name === "string" ? (name = name.toLowerCase()) && bot.nearestEntity((entity) => {
const ename = entity.name || entity.username const enames = [entity.username?.toLowerCase(), entity.name, entity.displayName?.toLowerCase()]
return name && ename ? ename == name : true return enames.includes(name)
}) : entity }) : name
console.log(entity) console.log("info entity:", entity)
if (!entity) { if (!entity) {
quiet || bot.chat("no entity") quiet || bot.chat("no entity")
return entity return entity