From da086011f8bf0a5147d9ee83cb6edfef143cc5d5 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 5 Jan 2016 15:37:43 +0100 Subject: [PATCH] fixes, ne help command for easy readme --- NadekoBot/Classes/Trivia.cs | 2 +- NadekoBot/Commands/DiceRollCommand.cs | 2 +- NadekoBot/Commands/DrawCommand.cs | 2 +- NadekoBot/Commands/HelpCommand.cs | 23 +++++++++++++++++++++++ NadekoBot/Modules/Administration.cs | 18 +++++++++--------- NadekoBot/Modules/Games.cs | 3 ++- NadekoBot/Modules/Music.cs | 4 ++-- 7 files changed, 39 insertions(+), 15 deletions(-) diff --git a/NadekoBot/Classes/Trivia.cs b/NadekoBot/Classes/Trivia.cs index d8827eb1..25f6b238 100644 --- a/NadekoBot/Classes/Trivia.cs +++ b/NadekoBot/Classes/Trivia.cs @@ -68,7 +68,7 @@ namespace NadekoBot public override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand("t") - .Description("Starts a game of trivia. Questions suck and repeat a lot atm.") + .Description("Starts a game of trivia.") .Alias("-t") .Do(DoFunc()); diff --git a/NadekoBot/Commands/DiceRollCommand.cs b/NadekoBot/Commands/DiceRollCommand.cs index 2d0de82e..ed0725c9 100644 --- a/NadekoBot/Commands/DiceRollCommand.cs +++ b/NadekoBot/Commands/DiceRollCommand.cs @@ -88,7 +88,7 @@ namespace NadekoBot public override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand("$roll") - .Description("Rolls 2 dice from 0-10. If you supply a number [x] it rolls up to 30 normal dice.\nUsage: $roll [x]") + .Description("Rolls 2 dice from 0-10. If you supply a number [x] it rolls up to 30 normal dice.\n**Usage**: $roll [x]") .Parameter("num", ParameterType.Optional) .Do(DoFunc()); } diff --git a/NadekoBot/Commands/DrawCommand.cs b/NadekoBot/Commands/DrawCommand.cs index ec1123a1..3cd89bdf 100644 --- a/NadekoBot/Commands/DrawCommand.cs +++ b/NadekoBot/Commands/DrawCommand.cs @@ -63,7 +63,7 @@ namespace NadekoBot public override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand("$draw") - .Description("Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck.\nUsage: $draw [x]") + .Description("Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck.\n**Usage**: $draw [x]") .Parameter("count", ParameterType.Optional) .Do(DoFunc()); } diff --git a/NadekoBot/Commands/HelpCommand.cs b/NadekoBot/Commands/HelpCommand.cs index c0f8146e..c4b34273 100644 --- a/NadekoBot/Commands/HelpCommand.cs +++ b/NadekoBot/Commands/HelpCommand.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Discord.Commands; using Discord.Legacy; +using System.IO; namespace NadekoBot { @@ -31,12 +32,34 @@ namespace NadekoBot await e.User.Send(helpstr); }; + public Action DoGitFunc() => e => { + 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"; + helpstr += "Command [alias] | Description | Usage\n"; + helpstr += "----------------|--------------|-------\n"; + lastCategory = com.Category; + } + helpstr += PrintCommandHelp(com); + } + helpstr = helpstr.Replace(NadekoBot.botMention, "@BotName"); + helpstr = helpstr.Replace("\n**Usage**:", " | ").Replace("**Usage**:", " | ").Replace("**Description:**", " | ").Replace("\n|", " | \n"); + File.WriteAllText("readme.md",helpstr); + return; + }; + public override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand("-h") .Alias(new string[] { "-help", NadekoBot.botMention + " help", NadekoBot.botMention + " h" }) .Description("Help command") .Do(DoFunc()); + cgb.CreateCommand("-hgit") + .Description("Help command stylized for github readme") + .Do(DoGitFunc()); } private string PrintCommandHelp(Command com) diff --git a/NadekoBot/Modules/Administration.cs b/NadekoBot/Modules/Administration.cs index 5f21ec1c..0ce38265 100644 --- a/NadekoBot/Modules/Administration.cs +++ b/NadekoBot/Modules/Administration.cs @@ -21,7 +21,7 @@ namespace NadekoBot.Modules commands.ForEach(cmd => cmd.Init(cgb)); cgb.CreateCommand(".sr").Alias(".setrole") - .Description("Sets a role for a given user.\nUsage: .sr @User Guest") + .Description("Sets a role for a given user.\n**Usage**: .sr @User Guest") .Parameter("user_name", Discord.Commands.ParameterType.Required) .Parameter("role_name", Discord.Commands.ParameterType.Required) .Do(async e => @@ -52,7 +52,7 @@ namespace NadekoBot.Modules }); cgb.CreateCommand(".rr").Alias(".removerole") - .Description("Removes a role from a given user.\nUsage: .rr @User Admin") + .Description("Removes a role from a given user.\n**Usage**: .rr @User Admin") .Parameter("user_name", Discord.Commands.ParameterType.Required) .Parameter("role_name", Discord.Commands.ParameterType.Required) .Do(async e => @@ -87,7 +87,7 @@ namespace NadekoBot.Modules }); cgb.CreateCommand(".r").Alias(".role").Alias(".cr") - .Description("Creates a role with a given name, and color.\n*Both the user and the bot must have the sufficient permissions.*") + .Description("Creates a role with a given name, and color.") .Parameter("role_name",Discord.Commands.ParameterType.Required) .Parameter("role_color",Discord.Commands.ParameterType.Optional) .Do(async e => @@ -123,7 +123,7 @@ namespace NadekoBot.Modules }); cgb.CreateCommand(".b").Alias(".ban") - .Description("Kicks a mentioned user\n*Both the user and the bot must have the sufficient permissions.*") + .Description("Kicks a mentioned user") .Do(async e => { try @@ -143,7 +143,7 @@ namespace NadekoBot.Modules cgb.CreateCommand(".k").Alias(".kick") .Parameter("user") - .Description("Kicks a mentioned user.\n*Both the user and the bot must have the sufficient permissions.*") + .Description("Kicks a mentioned user.") .Do(async e => { try @@ -162,7 +162,7 @@ namespace NadekoBot.Modules }); cgb.CreateCommand(".rvch") - .Description("Removes a voice channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*") + .Description("Removes a voice channel with a given name.") .Parameter("channel_name", Discord.Commands.ParameterType.Required) .Do(async e => { @@ -181,7 +181,7 @@ namespace NadekoBot.Modules }); cgb.CreateCommand(".vch").Alias(".cvch") - .Description("Creates a new voice channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*") + .Description("Creates a new voice channel with a given name.") .Parameter("channel_name", Discord.Commands.ParameterType.Required) .Do(async e => { @@ -200,7 +200,7 @@ namespace NadekoBot.Modules }); cgb.CreateCommand(".rch").Alias(".rtch") - .Description("Removes a text channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*") + .Description("Removes a text channel with a given name.") .Parameter("channel_name", Discord.Commands.ParameterType.Required) .Do(async e => { @@ -219,7 +219,7 @@ namespace NadekoBot.Modules }); cgb.CreateCommand(".ch").Alias(".tch") - .Description("Creates a new text channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*") + .Description("Creates a new text channel with a given name.") .Parameter("channel_name", Discord.Commands.ParameterType.Required) .Do(async e => { diff --git a/NadekoBot/Modules/Games.cs b/NadekoBot/Modules/Games.cs index ed905ca1..fd90834d 100644 --- a/NadekoBot/Modules/Games.cs +++ b/NadekoBot/Modules/Games.cs @@ -20,7 +20,7 @@ namespace NadekoBot.Modules { commands.ForEach(cmd => cmd.Init(cgb)); cgb.CreateCommand(">") - .Description("Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'.\n**Usage**: @BotName strike @User") + .Description("Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'.\n**Usage**: > strike @User") .Parameter("attack_type",Discord.Commands.ParameterType.Required) .Parameter("target",Discord.Commands.ParameterType.Required) .Do(async e => @@ -43,6 +43,7 @@ namespace NadekoBot.Modules cgb.CreateCommand("poketype") .Parameter("target", Discord.Commands.ParameterType.Required) + .Description("Gets the users element type. Use this to do more damage with strike") .Do(async e => { var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); diff --git a/NadekoBot/Modules/Music.cs b/NadekoBot/Modules/Music.cs index 52c59c81..83e35904 100644 --- a/NadekoBot/Modules/Music.cs +++ b/NadekoBot/Modules/Music.cs @@ -84,7 +84,7 @@ namespace NadekoBot.Modules { }); cgb.CreateCommand("testq") - .Description("Queue a song using a multi/single word name.\nUsage: `!m q Dream Of Venice`") + .Description("Queue a song using a multi/single word name.\n**Usage**: `!m q Dream Of Venice`") .Parameter("Query", ParameterType.Unparsed) .Do(async e => { var youtube = YouTube.Default; @@ -100,7 +100,7 @@ namespace NadekoBot.Modules { cgb.CreateCommand("q") .Alias("yq") - .Description("Queue a song using a multi/single word name.\nUsage: `!m q Dream Of Venice`") + .Description("Queue a song using a multi/single word name.\n**Usage**: `!m q Dream Of Venice`") .Parameter("Query", ParameterType.Unparsed) .Do(async e => { var youtube = YouTube.Default;