So I been trying to get the !trivia as a mod only command but every time if I put a if statement you have to be a mod where it should be it break the code... can anyone help me out please?
Code:
menu * {
  Trivia:trivia
}
on *:load:{
  write missed.txt Sorry guys, but you got it wrong!
  write missed.txt Aww cmon guys!
  write missed.txt You guys suck!
  write missed.txt I can't believe you got it wrong!
  write missed.txt You guys are miserable at this!
  hadd -m trivia strivia ison
  :start
  var %x = $input(Who would you like to set as your owner?,qe,Bot Owner)
  if (%x != $null) hadd -m trivia owner %x
  else goto start
  :chan
  var %y = $input(What channel would you like trivia to be for?,qe,Trivia Channel)
  if ($left(%y,1) == $chr(35)) hadd -m trivia chan %y
  else goto chan
}
on *:unload:{
  if ($isfile(reports.ini)) .remove -b reports.ini
  if ($isfile(questions.ini)) .remove -b questions.ini
  if ($isfile(scores.ini)) .remove -b scores.ini
  if ($isfile(missed.txt)) .remove -b missed.txt
  if ($hget(scores)) hfree $v1
  if ($hget(reports)) hfree $v1
  if ($hget(questions)) hfree $v1
  unset %streak*
  unset %wrong
  if ($hget(trivia)) hfree $v1
  .timertriv* off
}
on *:kick:#:{
  if ($knick == $me && $chan == $hget(trivia,chan)) {
    hadd -m trivia status off
    hdel trivia answer
    hdel trivia time
    .timertriv* off
    unset %streak*
    unset %wrong
  }
}
on *:start:{
  if (!$hget(scores)) hmake scores
  if (!$hget(reports)) hmake reports
  if (!$hget(questions)) hmake questions
  hload -i reports reports.ini
  hload -i questions questions.ini
  hload -i scores scores.ini
  if (!$hget(trivia)) hmake trivia
  hload -i trivia trivia.ini
  if (!$hget(trivia,owner)) {
    :start
    var %x = $input(Who would you like to set as your owner?,qe,Bot Owner)
    if (%x != $null) hadd -m trivia owner %x
    else goto start
  }
}
on *:join:#:{
  if ($chan == $hget(trivia,chan) && $nick == $me) {
    if ($dialog(trivia)) {
      did -e trivia 9
      did -b trivia 10
    }
  }
}
on *:part:#:{
  if ($nick == $me && $chan == $hget(trivia,chan)) {
    if ($dialog(trivia)) {
      did -e trivia 9
      did -b trivia 10,9
    }
    hadd -m trivia status off
    hdel trivia answer
    hdel trivia time
    .timertriv* off
    unset %streak*
    unset %wrong
  }
}
on *:exit:{
  hsave -i trivia trivia.ini
  hsave -i scores scores.ini
  hsave -i reports reports.ini
  hsave -i questions questions.ini
}
on *:connect: if ($dialog(trivia)) did -e trivia 9
on *:disconnect:{
  hadd -m trivia status off
  hdel trivia answer
  hdel trivia time
  .timertriv* off
  unset %streak*
  unset %wrong
  if ($dialog(trivia)) did -b trivia 10,9
}
on *:text:*:#:{
  if ($chan == $hget(trivia,chan)) {

    if ($regex($1,/^[!@.](?:trivia|start|triv(?:on|start))$/Si)) {
      if ($hget(trivia,status) != on) {
        hadd -m trivia status on
        .msg $chan $+( Trivia has been started by  $nick, !)
        .timertrivnew 1 2 new
        if ($dialog(trivia)) {
          did -b trivia 9
          did -e trivia 10
        }
      }

      else .msg $chan  Trivia is already  on  $+ !
    }
    if ($regex($1,/^[!@.](?:strivia|stop|triv(?:off|stop))$/Si)) {
      if ($hget(trivia,status) == on) {
        if ($nick $hgeT(trivia,strivia) $chan) {
          hadd -m trivia status off
          hdel trivia answer
          hdel trivia time
          .timertriv* off
          unset %streak*
          .msg $chan  Trivia has been stopped by  $nick $+  !
          if ($dialog(trivia)) {
            did -b trivia 10
            did -e trivia 9
          }
        }
        else .msg $chan you dont have access to that command
      }
      else .msg $chan  Trivia is already  off  $+ !
    }
    if ($strip($1-) == $hget(trivia,answer)) {
      unset %wrong
      var %time = $calc($calc($ticks - $hget(trivia,time)) / 1000)
      var %a = %streak [ $+ [ $nick ] ]
      unset %streak*
      set %streak [ $+ [ $nick ] ] $calc(%a + 1)
      hdel trivia answer
      .timertriv* off
      hinc -m scores $nick
      .msg $chan $+( ,$gettok(Way to go|That's the way|Wahoo|You got it,$r(1,4),124),$chr(32), ,$nick, !) The answer was  $strip($1-) $+  ! You got it in  %time  seconds! Your streak is  %streak [ $+ [ $nick ] ]  questions!(next question in 60 secs)
      if ($dialog(trivia) && $did(trivia,14).seltext == $nick) did -ra trivia 15 $hget(scores,$nick) Points
      .timertrivrightnew 1 100 new
    }
    if ($regex($1,/^[!@.](?:top(ten|score(s)?|10)?|scores)$/Si)) top10
    if ($1 == !score) {
      if ($2) {
        if (*has no rank yet !iswm $rank($2)) {
          .msg $chan   $+ $2  is ranked  $rank($2)  out of  $hget(scores,0).item  with  $score($2)  points!
        }
        else .msg $chan   $+ $2  isn't currently ranked.
      }
      else {
        if (*has no rank yet !iswm $rank($nick)) {
          .msg $chan  You  are ranked  $rank($nick)  out of  $hget(scores,0).item  with  $score($nick)  points!
        }
        else .msg $chan  You  aren't currently ranked.
      }
    }
    if ($1 == !report) {
      if ($2 <= $hget(questions,0).item && $3) {
        var %x = $hget(questions,$2)
        var %y = 1
        var %z = $hget(reports,1).item
        while $hgeT(reports,%y).item {
          if ($v1 > %z) var %z = $v1
          inc %y
        }
        hadd -m reports $calc(%z + 1) $gettok(%x,1,1) $chr(1) $3-
        .msg $chan  Thanks  $nick $+   $+ $chr(44),   $hgeT(trivia,owner)  will read your report shortly.
        if ($dialog(trivia)) {
          did -r trivia 51
          var %x = 1
          while $hget(reports,%x).item {
            did -a trivia 51 $gettok($hget(reports,$v1),1,1)
            inc %x
          }
          did -z trivia 51
        }
      }
      else .msg $chan  Syntax : !report < ques # > < problem >
    }
    if ($1 == !questions) .msg $chan  There are currently  $hget(questions,0).item  questions.
    if ($1 == !give) {
      if ($nick == $hget(trivia,owner)) {
        if ($3 isnum) {
          if (!$hget(scores,$2) && $dialog(trivia)) { did -a trivia 14 $2 | did -z trivia 14 }
          hadd -m scores $2 $3
          .msg $chan   $+ $2  now has  $score($2)  points.
          if ($dialog(trivia) && $did(trivia,14).seltext == $2) did -ra trivia 15 $3 Points
        }
        else .msg $chan  Syntax:  !give < nick > < points >
      }
      else .msg $chan  I don't believe you're  $hget(trivia,owner) $+  .
    }
    if ($regex($1,/^[!@.](?:triv(ia)?(?:help)|help)$/Si)) {
      .notice $nick ~*~Trivia Commands~*~
      .notice $nick !trivia ~ Starts trivia
      .notice $nick !strivia ~ Stops trivia $iif($hget(trivia,strivia) != ison,if you are) $iif($hget(trivia,strivia) == isop,op'd) $iif($hget(trivia,strivia) == isvoice,voiced)
      .notice $nick !score ~ Returns your rank and score
      .notice $nick !score <nick> ~ Returns <nick>'s rank and score
      .notice $nick !report <ques #> <problem> ~ report a question
      .notice $nick !trivhelp ~ Returns trivia help (this)
      .notice $nick !questions ~ Returns tumber of trivia questions
      .notice $nick !top10 ~ Returns top 10 scores
      if ($nick == $hget(trivia,owner)) .notice $nick !give <nick> <points> ~ Give someone points
    }
  }
}
alias -l new {
  var %chan = $hget(trivia,chan)
  var %total = $hget(questions,0).item
  var %number = $hget(questions,$r(1,%total)).item
  noop $regex($hget(questions,%number),/^(.+)(.+)(.+)(.+)$/i)
  hdel trivia answer
  hadd -m trivia answer $regml(4)
  .msg %chan $+( ~ * ~ Question  %number, / ,$hget(questions,0).item, ~ * ~)
  .msg %chan   $+ $regml(1)
  hadd -m trivia time $ticks
  .timertrivhint1 1 2 .msg %chan  Hint: $regml(2)
  .timertrivhint2 1 60 .msg %chan  Hint: $regml(3)
  .timertrivwrong 1 120 wrong
}
alias wrong {
  inc %wrong
  if (%wrong >= $hget(trivia,wrong)) {
    hadd -m trivia status off
    hdel trivia answer
    hdel trivia time
    .timertriv* off
    unset %streak*
    .msg $hget(trivia,chan)   %wrong  questions have gone by unanswered! Trivia has been stopped by  $me $+  !
    unset %wrong
    if ($dialog(trivia)) {
      did -b trivia 10
      did -e trivia 9
    }
  }
  else {
    .msg $hget(trivia,chan)   $+ $read(missed.txt) Get ready for the next question...
    ;if you want it to msg the answer, use the line below instead
    ;.msg $hget(trivia,chan)  The answer was  $hget(trivia,answer) $+  ! Get ready for the next question...
    unset %streak*
    .timertrivnewfromwrong 1 2 new
  }
}
alias -l top10 {
  var %d = 1, %w = @top10
  window -hn %w
  clear %w
  while $hget(scores,%d).item {
    aline %w $v1 $hget(scores,$v1)
    inc %d
  }
  filter -cteuww 2 32 %w %w
  var %k = 1, %k1
  while %k <= 10  {
    if ( $line(%w,%k) ) {
      tokenize 32 $v1
      if (%k == 1) var %x = $addtok(%x,  $+ $1 ~ $hget(scores,$1),44)
      if (%k == 2) var %x = $addtok(%x,  $+ $1 ~ $hget(scores,$1),44)
      if (%k == 3) var %x = $addtok(%x,  $+ $1 ~ $hget(scores,$1),44)
      elseif (%k isnum 4-10) var %x = $addtok(%x,  $+ $1 ~ $hget(scores,$1),44)
    }
    inc %k
  }
  .msg $hget(trivia,chan) $iif($line(%w,1),$replace(%x,$chr(44),$chr(44) $chr(32))%x, There are no high scores.)
}
alias -l rank {
  var %d = 1, %w = @top10, %n = $$1
  window -hn %w
  clear %w
  while $hget(scores,%d).item {
    aline %w $v1 $hget(scores,$v1)
    inc %d
  }
  filter -cteuww 2 32 %w %w
  return $iif($fline(%w,%n *,1),$ord($v1),$1 has no rank yet)
}
alias -l score {
  var %d = 1, %w = @top10, %n = $$1
  window -hn %w
  clear %w
  while $hget(scores,%d).item {
    aline %w $v1 $hget(scores,$v1)
    inc %d
  }
  filter -cteuww 2 32 %w %w
  return $iif($fline(%w,%n *,1),$gettok($line(%w,$v1),2,32),$1 has no score yet)
}
alias -l behind {
  if ($isid) {
    var %d = 1, %w = @top5, %n = $$1
    window -hn %w
    clear %w
    while $hget(scores,%d).item {
      aline %w $v1 $hget(scores,$v1)
      inc %d
    }
    filter -cteuww 2 32 %w %w
    return $iif($gettok($line(%w,$calc($fline(%w,%n *,1) - 1)),1,32) != 3,$v1,first)
  }
}
alias -l first {
  if ($isid) {
    var %d = 1, %w = @top5
    window -hn %w
    clear %w
    while $hget(scores,%d).item {
      aline %w $v1 $hget(scores,$v1)
      inc %d
    }
    filter -cteuww 2 32 %w %w
    return $iif($line(%w,1),$gettok($line(%w,2),1,32),error)
  }
}
dialog trivia {
  title "Trivia"
  size -1 -1 136 203
  option dbu
  tab "Settings", 1, 2 -1 132 201
  box "!Strivia Command", 5, 7 52 58 60, tab 1
  radio "Op", 6, 16 62 22 10, tab 1
  radio "Voice", 7, 16 77 25 10, tab 1
  radio "All Users", 8, 16 92 34 10, tab 1
  button "Start Trivia", 9, 26 30 37 12, disable tab 1
  button "Stop Trivia", 10, 65 30 37 12, disable tab 1
  box "Trivia Status", 12, 23 20 83 26, tab 1
  text "Owner:", 43, 10 125 19 8, tab 1
  edit "", 44, 32 124 74 10, tab 1 read autohs
  button "Edit", 45, 109 125 15 8, tab 1
  text "Channel:", 46, 10 139 23 8, tab 1
  edit "", 47, 32 138 74 10, tab 1 read autohs
  button "Edit", 48, 109 139 15 8, tab 1
  box "", 49, 7 117 121 35, tab 1
  box "Stop After N Wrong", 54, 70 52 58 60, tab 1
  radio "5 Questions", 55, 76 60 50 10, tab 1
  radio "10 Questions", 56, 76 71 50 10, tab 1
  radio "15 Questions", 57, 76 81 50 10, tab 1
  radio "20 Questions", 58, 76 91 50 10, tab 1
  radio "Unlimited", 59, 76 101 50 10, tab 1
  edit "", 60, 10 165 98 10, tab 1
  box "Add Missed Question Response", 62, 7 157 121 21, tab 1
  button "Add", 61, 109 165 15 8, disable tab 1
  tab "Reports", 2
  edit "", 50, 7 121 123 10, tab 2 read autohs
  list 51, 6 23 123 84, tab 2 sort size hsbar
  box "Reported Questions", 52, 4 15 127 94, tab 2
  box "Functions", 66, 16 144 98 20, tab 2
  button "Clear", 67, 50 152 30 10, disable tab 2
  button "Remove", 68, 20 152 30 10, disable tab 2
  button "Fix", 22, 80 152 30 10, disable tab 2
  box "Problem", 53, 5 113 127 20, tab 2
  tab "Questions", 3
  list 23, 6 23 123 84, tab 3 sort size hsbar
  button "Add *.txt", 24, 7 169 30 10, tab 3
  button "Add", 25, 37 169 30 10, tab 3
  button "Clear", 26, 97 169 30 10, disable tab 3
  button "Remove", 27, 67 169 30 10, disable tab 3
  box "Functions", 28, 5 161 124 20, tab 3
  box "Questions", 29, 4 15 127 94, tab 3
  edit "", 30, 30 136 82 10, tab 3 read autohs
  text "Hint 1:", 33, 6 126 18 8, tab 3
  edit "", 32, 30 147 82 10, tab 3 read autohs
  edit "", 31, 30 125 82 10, tab 3 read autohs
  text "Hint 2:", 35, 6 138 18 8, tab 3
  text "Answer:", 34, 6 148 22 8, tab 3
  box "", 36, 4 109 127 50, tab 3
  button "Edit", 37, 113 137 15 8, disable tab 3
  button "Edit", 39, 113 148 15 8, disable tab 3
  button "Edit", 38, 113 126 15 8, disable tab 3
  text "Question:", 40, 6 115 25 8, tab 3
  edit "", 41, 30 114 82 10, tab 3 read autohs
  button "Edit", 42, 113 115 15 8, disable tab 3
  tab "Scores", 4
  box "Scores", 13, 6 17 53 155, tab 4
  list 14, 9 25 47 144, tab 4 sort size hsbar
  edit "", 15, 66 136 59 10, tab 4 read autohs
  box "Score", 16, 64 128 64 21, tab 4
  button "Edit", 17, 75 78 37 12, disable tab 4
  button "Add", 18, 75 38 37 12, tab 4
  button "Remove", 19, 75 58 37 12, disable tab 4
  button "Clear", 20, 75 98 37 12, disable tab 4
  box "Functions", 21, 72 27 44 88, tab 4
  button "OK", 11, 48 185 37 12, ok cancel
}
alias trivia {
  if ($dialog(trivia)) dialog -x trivia trivia
  dialog -m trivia trivia
}
on *:dialog:trivia:*:*:{
  var %chan = $hgeT(trivia,chan)
  if ($devent == init) {
    if ($hget(trivia,wrong) == 5) did -c trivia 55
    if ($hget(trivia,wrong) == 10) did -c trivia 56
    if ($hget(trivia,wrong) == 15) did -c trivia 57
    if ($hget(trivia,wrong) == 20) did -c trivia 58
    if ($hget(trivia,wrong) !isnum) did -c trivia 59
    if ($hget(reports,1).item) did -e trivia 67
    did -a trivia 44 $hget(trivia,owner)
    if ($hget(reports)) {
      var %asdf = 1
      while $hget(reports,%asdf).item {
        did -a trivia 51 $gettok($hget(reports,$v1),1,1)
        inc %asdf
      }
      did -z trivia 51
    }
    did -a trivia 47 $hget(trivia,chan)
    if ($hget(questions,1).item) did -e trivia 26
    var %s = 1
    while $hgeT(questions,%s).item {
      did -a trivia 23 $gettok($hget(questions,$v1),1,1)
      inc %s
    }
    did -z trivia 23
    if ($hget(trivia,status) == on) did -e trivia 10
    else did -e trivia 9
    var %x = 1
    while $hget(scores,%x).item {
      did -a trivia 14 $v1
      inc %x
    }
    did -z trivia 14
    if ($hgeT(scores)) did -e trivia 20
    if (!$server) did -b trivia 9,10
    if ($hget(trivia,strivia) == isvoice) did -c trivia 7
    if ($hgeT(trivia,strivia) == isop) did -c trivia 6
    if ($hget(trivia,strivia) == ison || !$v1) { 
      did -c trivia 8 
    }
  }
  if ($devent == sclick) {
    if ($did == 9) {
      if ($hget(trivia,status) != on) {
        hadd -m trivia status on
        did -b trivia 9
        did -e trivia 10
        .msg %chan $+( Trivia has been started by  $me, !)
        .timertrivnew 1 2 new
      }
    }
    if ($did == 10) {
      if ($hget(trivia,status) == on) {
        hadd -m trivia status off
        hdel trivia answer
        hdel trivia time
        did -e trivia 9
        did -b trivia 10
        .timertriv* off
        unset %streak*
        .msg %chan  Trivia has been stopped by  $me $+  !
      }
    }
    if ($did == 14 && $diD(trivia,14).seltext != $null) {
      did -ra trivia 15 $hget(scores,$did(trivia,14).seltext) Points
      did -e trivia 19,17
    }
    if ($did isnum 6-8) {
      if ($did == 6) hadd -m trivia strivia isop
      if ($did == 7) hadd -m trivia strivia isvoice
      if ($did == 8) hadd -m trivia strivia ison
      if ($hget(trivia,wrong) == 5) did -c trivia 55
      if ($hget(trivia,wrong) == 10) did -c trivia 56
      if ($hget(trivia,wrong) == 15) did -c trivia 57
      if ($hget(trivia,wrong) == 20) did -c trivia 58
      if ($hget(trivia,wrong) !isnum) did -c trivia 59
    }
    if ($did == 20) {
      var %x = $input(Are you sure you would like to erase all scores?,cy,Clear All Scores)
      if (%x == $true) {
        hfree scores
        did -r trivia 14,15
        did -b trivia 20,17,19
        .msg %chan  All  scores cleared.
      }
    }
    if ($did == 19) {
      var %x = $input(Are you sure you would like to erase $did(trivia,14).seltext $+ 's score?,cy,Clear $did(trivia,14).seltext $+ 's Score)
      if (%x == $true) {
        .msg %chan   $+ $did(trivia,14).seltext $+ 's  score has been  cleared .
        hdel scores $did(trivia,14).seltext
        did -r trivia 15,14
        did -b trivia 17,19,20
        var %y = 1
        while $hgeT(scores,%y).item {
          did -a trivia 14 $v1
          inc %y
        }
        did -z trivia 14
        if ($hget(scores,1).item) did -e trivia 20
      }
    }
    if ($did == 18) {
      var %x = $input(Who would you like to add to the score list?,qe,Adding Score)
      if (%x != $null) {
        if ($numtok(%x,32) == 1) {
          var %y = $input(What would you like %x $+ 's score to be?,qe,%x $+ 's Score)
          if (%y isnum && %y) {
            hadd -m scores %x %y
            .msg %chan   $+ %x  now has   $+ %y  points!
            did -r trivia 15,14
            did -b trivia 17,19
            did -e trivia 20
            var %a = 1
            while $hget(scores,%a).item {
              did -a trivia 14 $v1
              inc %a
            }
            did -z trivia 14
          }
          else var %test = $input(The score must be a number!,ho,Error!)
        }
        else var %sos = $input(The name must be one word!,ho,Error!)
      }
      else var %asdf = $input(You must enter a name!,ho,Error!)
    }
    if ($did == 17) {
      var %x = $input(What would you like $did(trivia,14).seltext $+ 's new score to be?,qe,$did(trivia,14).seltext $+ 's Score,$hget(scores,$did(trivia,14).seltext))
      if (%x isnum) {
        hadd -m scores $did(trivia,14).seltext %x
        .msg %chan   $+ $did(trivia,14).seltext  now has  %x  points!
        did -ra trivia 15 %x Points
      }
      else var %asdf = $input(The score must be a number!,ho,Error!)
    }
    if ($did == 24) dialog $iif($dialog(txt),-v,-m) txt txt
    if ($did == 25) {
      var %ques = $input(What question would you like to add?,qe,Question)
      if (%ques != $null) {
        var %hint1 = $input(What would you like the first hint to be?,qe,Hint 1)
        if (%hint1 != $null) {
          var %hint2 = $input(What would you like the second hint to be?,qe,Hint 2)
          if (%hint2 != $null) {
            var %ans = $input(What would you like the answer to be?,qe,Answer)
            if (%ans != $null) {
              did -r trivia 23,30,31,32,41
              var %y = 1
              var %z = $hget(questions,1).item
              while $hget(questions,%y).item {
                if ($v1 > %z) var %z = $v1
                inc %y
              }
              hadd -m questions $calc(%z + 1) $+(%ques,$chr(1),%hint1,$chr(1),%hint2,$chr(1),%ans)
              did -e trivia 26
              var %b = 1
              while $hget(questions,%b).item {
                did -a trivia 23 $gettok($hget(questions,$v1),1,1)
                inc %b
              }
              did -z trivia 23
              did -b trivia 27,37,38,39,42
            }
          }
        }
      }
    }
    if ($did == 26) {
      var %x = $input(Are you sure you want to erase all questions?,cy,Remove All Questions)
      if (%x == $true) {
        did -r trivia 23,30,31,32,41
        hfree questions
        did -b trivia 26,27,37,38,39,42
      }
    }
    if ($did == 23 && $did(trivia,23).seltext != $null) {
      did -e trivia 27,37,38,39,42
      var %x = $hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data)
      noop $regex($hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data),/^(.+)(.+)(.+)(.+)$/i)
      did -ra trivia 31 $regml(2)
      did -ra trivia 30 $regml(3)
      did -ra trivia 32 $regml(4)
      did -ra trivia 41 $regml(1)
    }
    if ($did == 27) {
      var %x = $input(Are you sure you want to delete this question?,cy,Delete Question)
      if (%x == $true) {
        hdel questions %a $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
        did -r trivia 23,30,31,32,41
        var %y = 1
        while $hget(questions,%y).item {
          did -a trivia 23 $gettok($hget(questions,$v1),1,1)
          inc %y
        }
        did -b trivia 27,37,38,39,42
        did -z trivia 23
      }
    }
    if ($did == 38) {
      var %x = $input(What would you like hint 1 to be?,qe,Hint 1,$did(trivia,31).text)
      if (%x != $null) {
        var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
        var %a = $hget(questions,%y)
        var %z = $replace(%a,$gettok(%a,2,1),%x)
        hadd -m questions %y %z
        did -ra trivia 31 %x
      }
    }
    if ($did == 37) {
      var %as = $input(What would you like Hint 2 to be?,qe,Hint 2,$did(trivia,30).text)
      if (%as != $null) {
        var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
        var %a = $hget(questions,%y)
        var %z = $replace(%a,$gettok(%a,3,1),%as)
        hadd -m questions %y %z
        did -ra trivia 30 %as
      }
    }
    if ($did == 39) {
      var %sa = $input(What would you like the answer to be?,qe,Answer,$did(trivia,32).text)
      if (%sa != $null) {
        var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
        var %a = $hget(questions,%y)
        var %z = $replace(%a,$gettok(%a,4,1),%sa)
        hadd -m questions %y %z
        did -ra trivia 32 %sa
      }
    }
    if ($did == 42) {
      var %sas = $input(What would you like to rename the question as?,qe,Question,$did(trivia,41).text)
      if (%sas != $null) {
        var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
        var %a = $hget(questions,%y)
        var %z = $replace(%a,$gettok(%a,1,1),%sas)
        hadd -m questions %y %z
        did -ra trivia 41 %sas
        did -r trivia 23
        var %lmn = 1
        while $hget(questions,%lmn).item {
          did -a trivia 23 $gettok($hget(questions,$v1),1,1)
          inc %lmn
        }
        did -c trivia 23 $didwm(trivia,23,%sas $+ *)
        did -z trivia 23
      }
    }
    if ($did == 45) {
      var %x = $input(Who would you like to set as the owner?,qe,Owner,$hget(trivia,owner))
      if (%x != $null) {
        hadd -m trivia owner %x
        did -ra trivia 44 %x
      }
    }
    if ($did == 48) {
      var %x = $input(What would you like to set as the trivia channel?,qe,Trivia Channel,$hget(trivia,chan))
      if (%x != $null) {
        if ($left(%x,1) == $chr(35)) {
          hadd -m trivia chan %x
          did -ra trivia 47 %x
        }
        else var %y = $input(The channel must begin with $chr(35),ho,Error!)
      }
    }
    if ($did == 51 && $did(trivia,51).seltext != $null) {
      did -ra trivia 50 $gettok($hget(reports,$hfind(reports,$did(trivia,51).seltext $+ *,1,w).data),2,1)
      did -e trivia 68,22
    }
    if ($did == 22) {
      did -c trivia 3
      did -c trivia 23 $didwm(trivia,23,$did(trivia,51).seltext $+ *)
      var %x = $hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data)
      did -ra trivia 31 $gettok(%x,2,1)
      did -ra trivia 30 $gettok(%x,3,1)
      did -ra trivia 32 $gettok(%x,4,1)
      did -ra trivia 41 $gettok(%x,1,1)
      did -e trivia 27,37,38,39,42
    }
    if ($did == 67) {
      var %x = $input(Are you sure you would like to delete all reports?,cy,Erase All Reports)
      if (%x == $true) {
        did -r trivia 51,50
        hfree reports
      }
    }
    if ($did == 68) {
      var %x = $input(Are you sure you would like to remove this report?,cy,Remove Report)
      if (%x == $true) {
        did -b trivia 22,67,68
        hdel reports $hfind(reports,$did(trivia,51).seltext $+ *,1,w).data
        var %x = 1
        did -r trivia 51,50
        while $hget(reports,%x).item {
          did -a trivia 51 $gettok($hget(reports,$v1),1,1)
          inc %x
        }
        did -z trivia 51
        if ($hget(reports,1).data) did -e trivia 67
      }
    }
    if ($did isnum 55-58) {
      hadd -m trivia wrong $gettok($did(trivia,$did),1,32)
      if ($hget(trivia,strivia) == ison) did -c trivia 8
      if ($hget(trivia,strivia) == isvoice) did -c trivia 7
      if ($hgeT(trivia,strivia) == isop) did -c trivia 6
    }
    if ($did == 59) {
      hadd -m trivia wrong none
      if ($hget(trivia,strivia) == ison) did -c trivia 8
      if ($hget(trivia,strivia) == isvoice) did -c trivia 7
      if ($hgeT(trivia,strivia) == isop) did -c trivia 6
    }
    if ($did == 61) {
      write missed.txt $did(trivia,60).text
      did -r trivia 60
      did -b trivia 61
      var %x = $input(Missed Question Response Added!,io,Response Added)
    }
  }
  if ($devent == edit && $did == 60) {
    if ($did(trivia,60).text != $null) did -e trivia 61
    else did -b trivia 61
  }
}
alias -l hash {
  var %del = $$input(What delimeter seperates the question from the answer?,qe,Delimeter)
  var %x = 1
  unset %ques %ans
  while $read($qt($$1-),%x) {
    var %ques = $gettok($v1,1,%del)
    var %ans = $gettok($v1,2,%del)
    var %y = 1
    unset %hint1 %hint2
    while $gettok(%ans,%y,32) {
      var %hint1 = $addtok(%hint1,$chr(32) $+ $replace($v1,a,_,b,_,c,_,d,_,e,_,f,_,g,_,h,_,i,_,j,_,k,_,l,_,m,_,n,_,o,_,p,_,q,_,r,_,s,_,t,_,u,_,v,_,w,_,x,_,y,_,z,_,1,_,2,_,3,_,4,_,5,_,6,_,7,_,8,_,9,_,0,_),32)
      var %hint2 = $addtok(%hint2,$chr(32) $+ $left($v1,1) $+ $replace($mid($v1,2),a,_,b,_,c,_,d,_,e,_,f,_,g,_,h,_,i,_,j,_,k,_,l,_,m,_,n,_,o,_,p,_,q,_,r,_,s,_,t,_,u,_,v,_,w,_,x,_,y,_,z,_,1,_,2,_,3,_,4,_,5,_,6,_,7,_,8,_,9,_,0,_),32)
      inc %y
    }
    var %z = 1
    while $hget(questions,%z).item {
      inc %z
    }
    hadd -m questions $calc(%z + 1) $+(%ques,$chr(1),%hint1,$chr(1),%hint2,$chr(1),%ans)
    inc %x
  }
  did -r trivia 23
  var %b = 1
  while $hget(questions,%b).item {
    did -a trivia 23 $gettok($hget(questions,$v1),1,1)
    inc %b
  }
  did -z trivia 23
  did -e trivia 26
  did -b trivia 27,38,37,39,42
}

dialog -l txt {
  title "Add *.txt"
  size -1 -1 101 58
  option dbu
  button "...", 1, 84 6 11 10
  edit "", 2, 7 6 74 10, autohs
  radio "Question|Answer", 3, 7 30 53 10
  radio "Question|Hint1|Hint2|Answer", 4, 7 20 84 10
  button "OK", 5, 20 44 28 10, disable ok
  button "Cancel", 6, 53 44 28 10, cancel
}

on *:dialog:txt:*:*:{
  if ($devent == sclick) {
    if ($did == 1) {
      :a
      var %x = $$sfile($mircdir $+ *.txt,Select a .txt file,Select)
      if ($right(%x,4) != .txt) {
        var %y = $input(Please select a .txt file!,ho,Error!)
        goto a
      }
      else did -ra txt 2 %x
      if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
        did -e txt 5
      }
      else did -b txt 5
    }
    if ($did == 3 || $did == 4) {
      if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
        did -e txt 5
      }
      else did -b txt 5
    }
    if ($did == 5) {
      if ($isfile($did(txt,2))) {
        if ($did(txt,3).state == 1) {
          hash $did(txt,2)
        }
        elseif ($did(txt,4).state == 1) {
          addtxt $did(txt,2)
        }
      }
      else var %x = $input($did(txt,2) isn't a file!,ho,Error!)
    }
  }
  if ($devent == edit) {
    if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
      did -e txt 5
    }
    else did -b txt 5
  }
}
alias -l addtxt {
  var %as = $$input(What is the delimeter that seperates the hints $+ $chr(44) questions $+ $chr(44) and answers?,qe,Delimeter)
  if (%as isnum) {
    var %x = $qt($$1-)
    did -r trivia 23,30,31,32,41
    var %y = 1
    var %z = $hget(questions,1).item
    while $hget(questions,%y).item {
      if ($v1 > %z) var %z = $v1
      inc %y
    }
    var %a = 1
    while $read(%x,%a) {
      hadd -m questions $calc(%z + 1) $replace($v1,$chr(%as),$chr(1))
      inc %z
      inc %a
    }
    var %b = 1
    while $hget(questions,%b).item {
      did -a trivia 23 $gettok($hget(questions,$v1),1,1)
      inc %b
    }
    did -z trivia 23
    did -e trivia 26
    did -b trivia 27,38,37,39,42
  }
  else var %sumthin = $input(The delimeter must be a number!,ho,Error!)
}