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