Part of the problem is where you had the line. You set a timer in the line before, but timers don't take mutliple line commands, so to get around that, I created a small alias that is called from the timer.

The other part, that I can think of, is controlled by the code that calls the autovoice alias

Code:
 alias autovoice {
  var %x = $nick($1,0)
  while (%x) {
    if ($nick($1,%x).idle >= 1200) && ($nick($1,%x) != $me) && ($me isop $1) timer 1 2 idle.voice $1 $nick($1,%x)
    dec %x 
  }
}

alias idle.voice {
  .mode $1 -v $2
  .msg $1 $2 You've been devoiced because you haven't been saying nothing for over 20 minutes now
}