on NICK and on QUIT events are not related to channels. To figure out what channel(s) a user was on when they quit or change their nick you need to use $comchan. Note the pluralization of "channels" as there may be more than one channel.
on *:QUIT: {
var %i = 1
while ($comchan($nick, %i)) {
var %chan = $v1
echo -a one of the channels is %chan
inc %i
}
}
You can use each value of %chan in the above loop to do something with a channel both you and the user were on when they quit.