I'm not sure what help you're looking for. If it's the proper event to check for, then it's ON NICK
/help on nick
the ON NICK event doesn't return a channel in $chan, similar to the ON QUIT event (which you already have)
use $nick to reference the nick before the change & $newnick to reference it after the change. Some commands don't work well using $nick after it's been changed using the /nick command. Others work just fine.