So I have noticed a problem, each script that uses chat commands has its own handler. "What's the problem with that?" I hear you ask, lets think what would happen if I am running 10 different scripts all made by different people and two or more had the command !help, It wouldn't be good that's for sure. So to solve this problem I have created a well rounded fully functional chat command handler. <a href="https://gist.github.com/pigalot/5974253/c8bc959e0fa0358eda218ce5a5b69f72cc169aab" rel="nofollow">https://gist.github.com/pigalot/5974253/c8bc959e0fa0358eda218ce5a5b69f72cc169aab</a> It uses the commands formatted "!commandName [strings] [-OptionName values]". if the string has a space you can enclose it with quotes to keep it together. You can add commands by using "community.command.add" and passing it the command name and a object containing (* = required):
minArgs - The minimum number of arguments required.
maxArgs - The maximum number of arguments permitted.
gmOnly - You can set this to anything it just has to be there, if it exists the command will be only usable by someone with "(GM)" in there name.
typeList - This is an array of types for static arguments you want to receive. currently the only types are str (a string) and key (an option) key is the default.
options - A object with valid options for your command ie: { "lol":"this is a discription", "rofl":"another discription"} would be !test -lol something -rofl "something else"
handle* - a function with the profile of (args, who, isGM) args is a array of objects containing a value and if the argument was a option a key as well, ie "!test something -option value" would give [{ value:"something"},{key:"option", value:"value"}]. who is msg.who and isGM is a boolean.
syntax - is a string that will be shown after the command name in the help it should show the basic usage of the command it will be auto generated if not set.
Here is an example: on("ready", function() { obj = {}; obj.gmOnly = ""; obj.minArgs = 1; obj.typeList = ["str"]; obj.options = { "lol":"This has to do something :P" }; obj.handle = function(args) { log("test"); log(JSON.stringify(args)); }; community.command.add("test", obj); }); this would make the command !test, it requires one argument that will be a string and i can optionaly have as many -lol options as the user wants. When called it will log test and log its args in a JSON string. The add command returns a boolean indicating if the command has been added. Commands are automatic added to a help command (!?). Let me know what you think, I know this adds the problem of needing dependencies but without this sort of thing we will start having more and more problems as users start using more scripts.