I performed a search on the mass snippets on here and found this:
http://www.hawkee.com/snippet/3375/, exactly identical. You just added an else event in there. Please give the author proper credit, thanks.
Now onto your own coding:
Awful /\'s in front of commands, you advertise literally everywhere, you are missing a bracket, you don\'t check if the dialog is in use, and not sure who X is? Either way, you should just use the /ban command.