How to check if an event can move in a certain direction?

I wanted to have an event that constantly flees from the player when they get within range. I can do that fine. But I don't want the player to actually be able to touch the event (it's just a prop to set mood). The way the default pathfinding works, if it hits a wall, it won't move left or right, only forward. Is there a way to check which directions an event can and cannot move so I can say: "If Event X cannot move forward, then move left. If Event X cannot move left, move right. Etc..." I've Googled it, but got no relevant results.
$gameMap.event(event id).canPass(x, y, direction)
Thanks! So, x and y are the coordinates of the tile whose passability is being checked? So what if I wanted to check the tile directly ahead on the event's current path (whether it happens to be moving up/down/left/right)? Say the event's moving left and it hits a wall. Is there a generalized form for "forward" or do I just have to have a bunch of ifs? I guess I'd have to say, "If event x is facing left and cannot move left...if facing right and cannot move right...etc."
const event = $gameMap.event(id of event)
event.canPass(event.x, event.y, event.direction())

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-if-an-event-can-move-in-a-certain-direction.138369/