/// <summary> /// Creates an <see cref="EmbedBuilder"/> object for help for a particular command using reflection and attribute values. /// </summary> /// <param name="command"></param> /// <returns></returns> private EmbedBuilder GenerateEmbeddedHelpCommand(string command) { string helpImageUrl = Configuration.GetSection("images").GetSection("help")["64"]; string commandPrefix = Configuration["commandPrefix"]; string commandTitle = Format.Code($"{commandPrefix}{command}"); List <ModuleInfo> modules = Commands.Modules.Where(m => m.HasAttribute <HelpTitleAttribute>()) .OrderBy(m => m.GetAttribute <HelpOrderAttribute>()?.Order) .ToList(); CommandInfo commandInfo = Commands.Commands.GetCommand(command); EmbedBuilder embed = new EmbedBuilder().WithTitle($"Comando {commandTitle}") .WithColor(helpEmbedColor) .WithDescription(GlobalConfiguration.Constants.BLANK_SPACE) .WithThumbnailUrl(helpImageUrl) .AddField(Format.Bold("Descripción"), Format.Italics(commandInfo.Summary)); if (commandInfo.Parameters.Count > 0) { StringBuilder parameterBuilder = new StringBuilder(); foreach (ParameterInfo parameter in commandInfo.Parameters) { parameterBuilder.AppendLine($"{Format.Code($"<{parameter.Name}>")}: {Format.Italics(parameter.Summary)}"); } string parameters = parameterBuilder.ToString(); embed.AddField(Format.Bold("Parametros"), parameters); } else { embed.AddField(Format.Bold("Parametros"), Format.Italics("Ninguno.")); } if (commandInfo.Aliases.Count > 1) { IEnumerable <string> otherAliases = commandInfo.Aliases.Where(a => !a.IsEquivalentTo(command)); string aliases = string.Join(", ", otherAliases.Select(a => Format.Code($"{commandPrefix}{a}"))); embed.AddField(Format.Bold("Otros Alias"), aliases); } if (commandInfo.HasAttribute <HelpUsageExampleAttribute>()) { HelpUsageExampleAttribute attribute = commandInfo.GetAttribute <HelpUsageExampleAttribute>(); IEnumerable <string> examples = attribute.Examples; StringBuilder exampleBuilder = new StringBuilder(); foreach (string example in examples) { string exampleText = attribute.IsPreformatted ? example : Format.Code(example); exampleBuilder.AppendLine(exampleText); } embed.AddField(Format.Bold("Ejemplos"), exampleBuilder.ToString()); } return(embed); }