The first event handler creates a hashtable item that lives for 20 seconds, then dies. Then it finds how many hashtable items begin with flood, then does nothing if there's less than 5 of them.

As for monitoring if the channel is idle enough:

//echo -a $chan(#kaceysparkles).idle

shows how many seconds the channel has been idle. It doesn't count JOIN and QUIT and various other events, so if you want those to reset the idle back to zero, you'll have to trap those other events beyond :TEXT: and :ACTION: then do like I did below, where each time the :TEXT: event happens in channel, it updates the hashtable item to contain the newest $ctime value. Then you can have a timer that compares the current $ctime against $hget(kaceysparkles,idle) to see if it's been long enough.

Code:
ON *:TEXT:!command:#kaceysparkles:{
  var %unique $hget(kaceysparkles,unique) | inc %unique | hadd -m kaceysparkles unique %unique | hadd -m kaceysparkles idle $ctime
  hadd -u20 kaceysparkles flood $+ %unique $nick
  if ($hfind(kaceysparkles,flood*,0,w) < 5) return
  msg $chan commands msg 
}

ON *:TEXT:*:#kaceysparkles:{ hadd -m kaceysparkles idle $ctime }