public async Task Execute(IMessage rawMessage) { if (string.IsNullOrWhiteSpace(Command)) { StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine(":information_source: __**Here are all supported commands:**__ :information_source:"); strBuilder.AppendLine(); foreach (Type commandType in _commands.OrderBy(x => x.Name)) { var verbAttr = commandType.GetCustomAttribute <CommandVerbAttribute>(); if (verbAttr != null && !verbAttr.Hidden) { HelpTextRenderer helpRenderer = new HelpTextRenderer(commandType); strBuilder.Append(helpRenderer.GenerateHeaderHelp()); strBuilder.AppendLine(); } } await rawMessage.Channel.SendMessageAsync(strBuilder.ToString()); } else { if (_commands.TryGetCommandType(Command, out Type commandType)) { HelpTextRenderer helpRenderer = new HelpTextRenderer(commandType); await rawMessage.Channel.SendMessageAsync(helpRenderer.GetHelp()); } else { await rawMessage.Channel.SendMessageAsync($"\"{Command}\" is an unknown command. Type !help to list all available commands!"); } } }
public void RenderHeaderHelpTest(Type inputType, string expectedHeader) { HelpTextRenderer helpTextRenderer = new HelpTextRenderer(inputType); Assert.Equal(expectedHeader, helpTextRenderer.GenerateHeaderHelp().ToString()); }