Hey everyone! So I need help with a script that randomly selects a user from the viewer list and displays it in chat.
Code
on *:text:*!slap*:#troyl:{
alias randuser {
  VAR %x = 1
  WHILE ($hget(activeusers, %x).item != $null) {
    VAR %nick $v1
    IF (!$1) { IF ((%nick ison %mychan) || ($calc($hget(activeusers, %nick) + 90) >= %activetime)) VAR %activelist %activelist %nick }
    ELSEIF ($1 == other) { IF (((%nick isOn %mychan) || ($calc($hget(activeusers, %nick) + 90) >= %activetime)) && (%nick != $nick)) VAR %activelist %activelist %nick }
    ELSEIF ($1 == notme) { IF (((%nick isOn %mychan) || ($calc($hget(activeusers, %nick) + 90) >= %activetime)) && (%nick != %streamer)) VAR %activelist %activelist %nick }
    ELSEIF ($1 == othernotme) { IF (((%nick isOn %mychan) || ($calc($hget(activeusers, %nick) + 90) >= %activetime)) && (%nick != %streamer) && (%nick != $nick)) VAR %activelist %activelist %nick }
    ELSEIF ($1 == list) { IF ((%nick isOn %mychan) || ($calc($hget(activeusers, %nick) + 90) >= %activetime)) VAR %activelist %activelist %nick }
    ELSE BREAK
    INC %x
    }
  IF ($1 == list) RETURN %activelist
  ELSE {
    VAR %randuser $gettok(%activelist, $rand(1, $numtok(%activelist, 32)), 32)
    IF (%randuser != $null) RETURN %randuser
    msg $chan slapped %nick
    ELSE RETURN $nick
    }
  }

This is what i have so far, i got the alias from a website. But every time i do the command it says "slapped" it doesnt display a user from my viewer list. I've been trying to put the msg $chan in different places to see if it would work, i just dont know how to use an alias and connect that with a twitch command. Any help with this would be greatly appreciated! Thanks!