Decently sized C#6 refactor

Also removed unused using statements
This commit is contained in:
Kwoth
2015-12-12 23:39:58 +01:00
parent 1847ddbbe2
commit d9657436a4
10 changed files with 161 additions and 221 deletions

View File

@@ -6,32 +6,29 @@ namespace NadekoBot
{
class HelpCommand : DiscordCommand
{
public override Func<CommandEventArgs, Task> DoFunc()
public override Func<CommandEventArgs, Task> DoFunc() => async e =>
{
return async e =>
{
string helpstr = "Official repo: **github.com/Kwoth/NadekoBot/** \n";
string helpstr = "Official repo: **github.com/Kwoth/NadekoBot/** \n";
string lastCategory = "";
foreach (var com in client.Commands().AllCommands)
{
if (com.Category != lastCategory)
{
helpstr += "\n`----`**`" + com.Category + "`**`----`\n";
lastCategory = com.Category;
}
helpstr += PrintCommandHelp(com);
}
helpstr = helpstr.Replace(NadekoBot.botMention, "@BotName");
while (helpstr.Length > 2000)
{
var curstr = helpstr.Substring(0, 2000);
await client.SendMessage(e.User, curstr.Substring(0, curstr.LastIndexOf("\n")+1));
helpstr = curstr.Substring(curstr.LastIndexOf("\n")+1) + helpstr.Substring(2000);
}
await client.SendMessage(e.User, helpstr);
};
}
string lastCategory = "";
foreach (var com in client.Commands().AllCommands)
{
if (com.Category != lastCategory)
{
helpstr += "\n`----`**`" + com.Category + "`**`----`\n";
lastCategory = com.Category;
}
helpstr += PrintCommandHelp(com);
}
helpstr = helpstr.Replace(NadekoBot.botMention, "@BotName");
while (helpstr.Length > 2000)
{
var curstr = helpstr.Substring(0, 2000);
await client.SendMessage(e.User, curstr.Substring(0, curstr.LastIndexOf("\n") + 1));
helpstr = curstr.Substring(curstr.LastIndexOf("\n") + 1) + helpstr.Substring(2000);
}
await client.SendMessage(e.User, helpstr);
};
public override void Init(CommandGroupBuilder cgb)
{