$event is filled only during the ON EVENT events, to tell what kind of event (if any) the code is executing during.

on *:TEXT:*:#:{ echo -s this code is executing during the $event event }
on *:ACTION:*:#:{ echo -s this code is executing during the $event event }

Even if the ON EVENT calls another alias, the code within that alias is also given the $event filled.

On the other hand, something executing from the command-line or from a timer sees $event being $null.