chacha, that's good to use $comchan($2,0) with the .op property. But you cannot use $v1 to have it returned as a channel. $comchan($2,0).op returns $true if the running client is opped. It'll become
ban -k $true $2 2
and that won't work. You should have used:
while $comchan($2,%x).op {
ban -k $comchan($2,%x) $2 2 unacceptable channel detected!
Yes, I accidentally put a -u switch there.