I believe you are missing a closing bracket.
I also do not think the "%random == N." should have the period.
The way your on text is set up right now will trigger the script if "!rand" is anywhere in the message. If you want it to trigger on the message "!rand" only then remove the asterisks (they are wildcards)
You can optimize your code in many different ways, one being the use of text files (.txt) and the $read() function. Even if you do not use it for this specific snippet, it is good to know (/help $read).
Off topic: you mispelled appearance in your code.
Edit: just realized your case 15 will message #kirby. I believe you meant to put $chan