A little problem is that many of these won't work in queries, and will generate errors (eg. NICK no such channel) when they are used there. (mainly the ones that kick)
Personally, what I would suggest is replacing any instance of $chan with:
$$iif(#,#,$iif(#$? ischan,$!))
This will let you/the user choose a channel to kick from if they are using the command from a query, but will not generate an error if no channel is chosen, nor if you aren't on the channel written. (A channel won't have to be used if the command is used from the a nicklist.)
Edit - For the message commands, however, I would just replace msg $chan with say