Removed redundant JSON object in configuration
This commit is contained in:
parent
6860bf98de
commit
bdc0d223cd
2 changed files with 17 additions and 29 deletions
|
@ -22,19 +22,10 @@ namespace Noikoio.RegexBot.Module.ModCommands
|
|||
{
|
||||
throw new RuleImportException("Configuration for this section is invalid.");
|
||||
}
|
||||
var config = (JObject)inconf;
|
||||
|
||||
// Command instance creation
|
||||
var commands = new Dictionary<string, Command>(StringComparer.OrdinalIgnoreCase);
|
||||
var commandconf = config["Commands"];
|
||||
if (commandconf != null)
|
||||
{
|
||||
if (commandconf.Type != JTokenType.Object)
|
||||
{
|
||||
throw new RuleImportException("CommandDefs is not properly defined.");
|
||||
}
|
||||
|
||||
foreach (var def in commandconf.Children<JProperty>())
|
||||
foreach (var def in inconf.Children<JProperty>())
|
||||
{
|
||||
string label = def.Name;
|
||||
var cmd = Command.CreateInstance(instance, def);
|
||||
|
@ -45,7 +36,6 @@ namespace Noikoio.RegexBot.Module.ModCommands
|
|||
|
||||
commands.Add(cmd.Trigger, cmd);
|
||||
}
|
||||
}
|
||||
_cmdInstances = new ReadOnlyDictionary<string, Command>(commands);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ ModCommands is the name of the component that provides the ability for one to cr
|
|||
Sample within a [server definition](serverdef.html):
|
||||
```
|
||||
"ModCommands": {
|
||||
"Commands": {
|
||||
"Kick": { // a plain and simple kick command
|
||||
"type": "kick",
|
||||
"command": "!!kick"
|
||||
|
@ -16,11 +15,10 @@ Sample within a [server definition](serverdef.html):
|
|||
"successmsg": "Yay! $target got banned!\nhttps://i.imgur.com/i4CIBtT.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Definition structure
|
||||
Commands are defined within a JSON object named `Commands` within another object named `ModCommands`. They are defined by means of name/value pairs, with the name serving as its label.
|
||||
Commands are defined within a `ModCommands` object, itself within a [server definition](serverdef.html). They are defined by means of name/value pairs, with the name serving as its label.
|
||||
|
||||
The following values are **required** in a definition:
|
||||
* type (*string*) - Specifies the type of behavior that the command should take.
|
||||
|
|
Loading…
Reference in a new issue