@@ -12,19 +12,66 @@ import (
1212 "github.com/maxsupermanhd/FactoCord-3.0/support"
1313)
1414
15- // ModCommandUsage ...
16- var ConfigCommandUsage = "Usage: $config save | load | get <path> | set <path> <value>"
15+ var ConfigCommandDoc = support.CommandDoc {
16+ Name : "config" ,
17+ Usage : "$config save | load | get <path> | set <path> <value>?" ,
18+ Doc : "command manages FactoCord's config" ,
19+ Subcommands : []support.CommandDoc {
20+ {Name : "save" , Doc : "command saves FactoCord's config from memory to `config.json`" },
21+ {
22+ Name : "load" ,
23+ Doc : "command loads the config from `config.json`.\n " +
24+ "Any unsaved changes after the last `$config save` command will be lost." ,
25+ },
26+ {
27+ Name : "get" ,
28+ Usage : "$config get <path>?" ,
29+ Doc : "command outputs the value of a config setting specified by <path>.\n " +
30+ "All path members are separated by a dot '.'\n " +
31+ "If the path is empty, it outputs the whole config.\n " +
32+ "Examples:\n " +
33+ "```\n " +
34+ "$config get\n " +
35+ "$config get admin_ids\n " +
36+ "$config get admin_ids.0\n " +
37+ "$config get command_roles\n " +
38+ "$config get command_roles.mod\n " +
39+ "$config get messages\n " +
40+ "```" ,
41+ },
42+ {
43+ Name : "set" ,
44+ Usage : "$config set <path>\n " +
45+ "$config set <path> <value>" ,
46+ Doc : "command sets the value of a config setting specified by <path>.\n " +
47+ "This command can set only simple types such as strings, numbers, and booleans.\n " +
48+ "If no value is specified, this command deletes the value if possible, otherwise it sets it to a zero-value (0, \" \" , false).\n " +
49+ "To add a value to an array or an object specify it's index as '*' (e.g. `$config set admin_ids.* 1234`).\n " +
50+ "Changes made by this command are not automatically saved. Use `$config save` to do it.\n " +
51+ "Examples:" +
52+ "```\n " +
53+ "$config set prefix !\n " +
54+ "$config set game_name \" Factorio 1.0\" \n " +
55+ "$config set ingame_discord_user_colors true\n " +
56+ "$config set admin_ids.0 123456789\n " +
57+ "$config set admin_ids.* 987654321\n " +
58+ "$config set command_roles.mod 55555555\n " +
59+ "$config set messages.server_save **:mango: Game saved!**\n " +
60+ "```" ,
61+ },
62+ },
63+ }
1764
1865// ModCommand returns the list of mods running on the server.
1966func ConfigCommand (s * discordgo.Session , args string ) {
2067 if args == "" {
21- support .SendFormat (s , ConfigCommandUsage )
68+ support .SendFormat (s , "Usage: " + ConfigCommandDoc . Usage )
2269 return
2370 }
2471 action , args := support .SplitDivide (args , " " )
2572 args = strings .TrimSpace (args )
2673 if _ , ok := commands [action ]; ! ok {
27- support .SendFormat (s , ConfigCommandUsage )
74+ support .SendFormat (s , "Usage: " + ConfigCommandDoc . Usage )
2875 return
2976 }
3077 res := commands [action ](args )
0 commit comments