diff --git a/NadekoBot/Classes/SearchHelper.cs b/NadekoBot/Classes/SearchHelper.cs index 9525ec63..42f70398 100644 --- a/NadekoBot/Classes/SearchHelper.cs +++ b/NadekoBot/Classes/SearchHelper.cs @@ -377,5 +377,13 @@ namespace NadekoBot.Classes return url; } } + + public static string ShowInPrettyCode(IEnumerable items, Func howToPrint, int cols = 3) + { + var i = 0; + return "```xl\n" + string.Join("\n", items.GroupBy(item => (i++) / cols) + .Select(ig => string.Join("", ig.Select(el => howToPrint(el))))) + + $"\n```"; + } } } diff --git a/NadekoBot/Modules/Help/HelpModule.cs b/NadekoBot/Modules/Help/HelpModule.cs index 1b8ad4ec..0b17e336 100644 --- a/NadekoBot/Modules/Help/HelpModule.cs +++ b/NadekoBot/Modules/Help/HelpModule.cs @@ -1,5 +1,6 @@ using Discord.Commands; using Discord.Modules; +using NadekoBot.Classes; using NadekoBot.Classes.Help.Commands; using NadekoBot.Extensions; using NadekoBot.Modules.Permissions.Classes; @@ -54,10 +55,8 @@ namespace NadekoBot.Modules.Help } var i = 0; if (module != "customreactions" && module != "conversations") - await e.Channel.SendMessage("`List Of Commands:`\n```xl\n" + - string.Join("\n", cmdsArray.GroupBy(item => (i++) / 3) - .Select(ig => string.Join("", ig.Select(el => $"{el.Text,-15}" + $"{"[" + el.Aliases.FirstOrDefault() + "]",-8}")))) - + $"\n```") + await e.Channel.SendMessage("`List Of Commands:`\n" + SearchHelper.ShowInPrettyCode(cmdsArray, + el => $"{el.Text,-15}{"[" + el.Aliases.FirstOrDefault() + "]",-8}")) .ConfigureAwait(false); else await e.Channel.SendMessage("`List Of Commands:`\n• " + string.Join("\n• ", cmdsArray.Select(c => $"{c.Text}")));