since you call this from a raw numeric where $chan is not defined, you'll need to either find the channel name as one of the other parameters, or send it as a variable.

In this case, the channelname is $2 so you can pass $2 and $6 to your alias, and not use $chan at all.

Also note that $7 contains the @, so you could use
if (@ isin $7) instead of using ISOP, though it's a little more complicated if you need to recognize other channel modes as being op, such as when someone has & super@op but not @normal@op