When you join a channel, you are not an op. So $nick will never be you in an on JOIN at the same time that you are an op and that part will never trigger. It is possible to use a timer, but that's unreliable because you won't know how quickly you'll be an op. If you need something to happen when you join and the become an op, just put the code in an on OP event where $opnick = you.

Invision Support
#Invision on irc.irchighway.net