That's because the sock events are completely seperate to the trigger. You can tell because of the completely closed { brackets } you have either
on *:event {
OR
alias etc {
starting the next section so it's an internal run part of the script and doesn't have an $chan to send to.