summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DiscoBot/Auxiliary/CommandInfo.cs9
-rw-r--r--DiscoBot/Commands/Gm.cs18
-rw-r--r--DiscoBot/Commands/Help.cs20
-rw-r--r--DiscoBot/Help.json21
4 files changed, 55 insertions, 13 deletions
diff --git a/DiscoBot/Auxiliary/CommandInfo.cs b/DiscoBot/Auxiliary/CommandInfo.cs
index b08ba1b..90fbbc7 100644
--- a/DiscoBot/Auxiliary/CommandInfo.cs
+++ b/DiscoBot/Auxiliary/CommandInfo.cs
@@ -8,7 +8,7 @@ namespace DiscoBot.Auxiliary
{
public struct CommandInfo
{
- public CommandInfo(string name, string description, string scope)
+ public CommandInfo(string name, string[] description, string scope)
{
this.Name = name;
this.Scope = scope;
@@ -19,6 +19,11 @@ namespace DiscoBot.Auxiliary
public string Scope { get; }
- public string Description { get; }
+ public string[] Description { get; }
+
+ public string GetDescription()
+ {
+ return this.Description.Aggregate((s, c) => s + c);
+ }
}
}
diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs
index 57e985b..b0d9def 100644
--- a/DiscoBot/Commands/Gm.cs
+++ b/DiscoBot/Commands/Gm.cs
@@ -17,7 +17,15 @@
{
string res;
string name;
- if ((givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am")) && givenName.Length > 1)
+
+ if (givenName.Length == 0)
+ {
+ res = " \nDu bist " + Dsa.Relation[this.Context.User.Username] + "!\n \n";
+
+ return this.ReplyAsync("```xl\n" + res + "\n```");
+ }
+
+ if (givenName.Length > 1 && (givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am")) )
{
name = givenName.Skip(1).Aggregate((s, c) => s + c); // (Skip(1)) don't use the first element; Aggregate: take source s and do operation s = s+c for all elements
}
@@ -28,8 +36,12 @@
var character = Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(name, x.Name)).First(); // usage of compareEasy
- Dsa.Relation[this.Context.User.Username] = character.Name;
- res = " \nWillkommen " + character.Name + "!\n \n";
+
+
+
+ Dsa.Relation[this.Context.User.Username] = character.Name;
+ res = " \nWillkommen " + character.Name + "!\n \n";
+
return this.ReplyAsync("```xl\n" + res + "\n```");
}
diff --git a/DiscoBot/Commands/Help.cs b/DiscoBot/Commands/Help.cs
index 2ba3fb6..d6c0e68 100644
--- a/DiscoBot/Commands/Help.cs
+++ b/DiscoBot/Commands/Help.cs
@@ -25,13 +25,23 @@ namespace DiscoBot.Commands
reader.Read(); // step into structure, until the array starts
reader.Read();
reader.Read();
- var test = new JsonSerializer().Deserialize<List<CommandInfo>>(reader); // Deserialize Data and create CommandInfo Struct
- Commands.AddRange(test); // Add new CommandInfos to List
+
+ try
+ {
+ var test = new JsonSerializer().Deserialize<List<CommandInfo>>(reader); // Deserialize Data and create CommandInfo Struct
+
+ Commands.AddRange(test); // Add new CommandInfos to List
+ }
+ catch (Exception e)
+ {
+ // ignored
+ }
}
public static List<CommandInfo> Commands { get; } = new List<CommandInfo>();
[Command("help"), Summary("prints the help menu.")]
+ [Alias("Help", "man", "Man")]
public async Task ShowHelpAsync(string command = "")
{
if (command.Equals(string.Empty)) // return generic Help
@@ -40,10 +50,12 @@ namespace DiscoBot.Commands
return;
}
+
+
// return command specific help
- var com = Commands.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command)).First(); // get best fit command
+ var com = Commands.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
- await this.ReplyAsync("```\n" + com.Name + "\n" + com.Description + "\n```");
+ await this.ReplyAsync("```xl\n" + com.GetDescription() + "\n```");
}
}
}
diff --git a/DiscoBot/Help.json b/DiscoBot/Help.json
index ffbbaf3..737ddf7 100644
--- a/DiscoBot/Help.json
+++ b/DiscoBot/Help.json
@@ -3,22 +3,35 @@
{
"Name": "List",
"Scope": "All",
- "Description": "Testbeschreibung"
+ "Description": [ "Testbeschreibung" ]
},
{
"Name": "LE",
"Scope": "All",
- "Description": "Verändert Leben - im wahrsten Sinne des Wortes"
+ "Description": [
+ "Use !LE to display, set, or change LE value\n\n",
+ " !LE Display values\n",
+ " !LE 30 Set LE to 30\n",
+ " !LE 30 Set LE to 30\n",
+ " !LE +5 Increment LE by 5 (up to the maximum)\n",
+ " !LE ++5 Increment LE by 5 (ignoring the maximum)\n",
+ " !LE -5 Decrease LE by 5\n \n"
+ ],
},
{
"Name": "AE",
"Scope": "All",
- "Description": "Verändert ASTRALPUNKTE"
+ "Description": ["Use !AE (or !Asp) to display, set, or change AE/Asp value\n\n",
+ " !AE Display values\n",
+ " !AE 30 Set Asp to 30\n",
+ " !AE +5 Increment Asp by 5 (up to the maximum)\n",
+ " !AE ++5 Increment Asp by 5 (ignoring the maximum)\n",
+ " !AE -5 Decrease Asp by 5 (down to 0)\n"],
},
{
"Name": "Gm",
"Scope": "Meister",
- "Description": "Gm Aktionen"
+ "Description": ["Gm Aktionen"]
}
]
}