If you insist on using 6.14, then here is a different method to clean up the channel list that will work for you. The blue line is the only line from the previous code that I changed. It calls an added alias at the bottom.

Code:
on !*:JOIN:[color:red]#YourChannel[/color]:{
  hadd -mu3 temp.whois $nick $chan
  whois $nick
}

raw 319:*:{
  if ($hget(temp.whois,$2)) {
    [color:blue]var %chans = $_noprefix($3-)[/color]
    var %bad.chans = [color:red]#BadChannel1 #BadChannel2 #BadChannelN[/color]
    var %i = 1, %l = $numtok(%bad.chans,32)
    while (%i <= %l) {
      if ($istok(%chans,$gettok(%bad.chans,%i,32),32)) {
        ban -ku300 $hget(temp.whois,$2) $2 You may not join $hget(temp.whois,$2) while on $gettok(%bad.chans,%i,32) $+ !
        return
      }
      inc %i
    }
  }
}

alias _noprefix {
  if (!$isid) return
  var %chans = $1-
  var %i = 1, %l = $numtok(%chans,32), %tmp
  while (%i <= %l) {
    %tmp = $+(%tmp,$chr(32),$chr(35),$gettok($gettok(%chans,%i,32),$iif($numtok($gettok(%chans,%i,32),35) > 1,2,1),35)))
    inc %i
  }
  return %tmp
}