A big improvement, I think, would be maybe a timed query only ignore after denying a query...this way users couldn\'t spam you with popup windows by rapidly querying you; you just deny it once and there you go.
Another thing is I would try to use $input rather than a dialog in this case. You don\'t have to, but if you decide not to then consider a dynamic name for the dialog (so the dialog open command would look like /dialog $+(query.,%qnum) query) so that you can have multiple dialogs open at the same time. The problem with what you have now is that if Person A queries you and while you are deciding whether to accept or decline, Person B queries you, you\'ll get some errors since it tries to open up another dialog named query, but it can\'t since there\'s already one open.