To make your script more user friendly, I'd suggest adjusting some things about your command parsing. Right now, you expect a command like: !train,Tool,healer's kit But will reject: !train,tool,healer's kit Anything that you'll be inspecting in code, I would suggest sanitizing to either lowercase or uppercase before passing it on to your functions. Furthermore, this will fail: !train, Tool, healer's kit People are used to typing spaces after commas and won't understand why that doesn't work. At a minimum, I'd suggest accepting spaces around the commas that are splitting up the arguments of your commands: var args = msg.content.split(/\s*,\s*/); However, there is something of an informal standard with API scripts, where arguments are separated with " --": !train --tool --healer's kit which you can do using: var args = msg.content.split(/\s+--/); If you aren't overly attached to using , for a separator, I'd suggest adopting that style. It has the added benefit that " --" doesn't appear in english naturally, so you can use it with taking whole descriptions without issues: !train --weapon --martial --note|Studied with Master Torin, 3rd knight of his Majesty. In the interest of more maintainable code, I'd suggest organizing your GM-only commands more like this: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 handleInput = function (msg) {
if (msg.type !== "api" ) {
return ;
}
let args = msg.content.split( /\s+--/ );
if (playerIsGM(msg.playerid)) {
switch (args[ 0 ]) {
case '!setdown' :
setdown(args[ 1 ],args[ 2 ],msg);
downmenu(msg);
return ;
case '!setdc' :
state.down.now.dc = args[ 1 ];
return ;
case '!setchar' :
state.down.now.character = args[ 1 ];
return ;
case '!settrain' :
state.down.now.train = args[ 1 ];
trainmenu( "Tool" ,msg);
return ;
}
}
switch (args[ 0 ]) {
case '!down' :
downmenu(msg);
break ;
case '!brew' :
brew(args[ 1 ],args[ 2 ],msg);
break ;
case '!craft' :
craft(args[ 1 ],args[ 2 ],msg);
break ;
case '!work' :
work(args[ 1 ],args[ 2 ],msg);
break ;
case '!trainmenu' :
trainmenu(args[ 1 ],msg);
break ;
case '!crime' :
crimemenu(args[ 1 ],args[ 2 ],msg);
break ;
case '!research' :
research(args[ 1 ],msg);
break ;
case '!commit' :
crime(args[ 1 ],args[ 2 ],args[ 3 ],args[ 4 ]);
break ;
case '!setvalue' :
state.down.now.crimeval = Number (args[ 1 ]);
crimemenu(args[ 2 ],args[ 3 ],args[ 4 ])
break ;
case '!settrain' :
state.down.now.train = args[ 1 ];
trainmenu( "Tool" ,msg);
break ;
case '!train' :
train(args[ 1 ],args[ 2 ],msg);
downmenu(msg);
break ;
}
}, That will let you execute GM-only commands if the player is a gm and if those commands were specified, but not duplicate calling all the any player commands.