Moved Help to its own file, created administration module which now contains help. I will add more commands to it in the future.

This commit is contained in:
Master Kwoth
2015-12-06 12:57:29 +01:00
parent b393a5932f
commit 654099afa4
6 changed files with 71 additions and 55 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Threading.Tasks;
using Discord.Commands;
namespace NadekoBot
{
class HelpCommand : DiscordCommand
{
public override Func<CommandEventArgs, Task> DoFunc()
{
return async e =>
{
string helpstr = "";
foreach (var com in client.Commands().AllCommands)
{
helpstr += "&###**#" + com.Category + "#**\n";
helpstr += PrintCommandHelp(com);
}
while (helpstr.Length > 2000)
{
var curstr = helpstr.Substring(0, 2000);
await client.SendPrivateMessage(e.User, curstr.Substring(0, curstr.LastIndexOf("&")));
helpstr = curstr.Substring(curstr.LastIndexOf("&")) + helpstr.Substring(2000);
}
await client.SendPrivateMessage(e.User, helpstr);
};
}
public override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand("-h")
.Alias(new string[] { "-help", NadekoBot.botMention + " help", NadekoBot.botMention + " h" })
.Description("Help command")
.Do(DoFunc());
}
private string PrintCommandHelp(Command com)
{
var str = "`" + com.Text + "`\n";
foreach (var a in com.Aliases)
str += "`" + a + "`\n";
str += "Description: " + com.Description + "\n";
return str;
}
}
}