Пример #1
0
        public async Task DumpHelp(ICommand command)
        {
            var result  = new StringBuilder();
            var preface = new StringBuilder("<div class=\"row\"><div class=\"col-lg-12 section-heading\" style=\"margin-bottom: 0px\">\n<h3><img class=\"feature-icon-big\" src=\"img/compass.png\"/>Quick navigation</h3>\n");
            int counter = 0;

            foreach (var module in _frameworkReflector.Modules.Where(x => !x.Hidden))
            {
                var anchor      = WebsiteWalker.GetModuleWebAnchor(module.Name);
                var description = ConvertToHtml(ReplacePlaceholders(module.Description));
                preface.AppendLine($"<p class=\"text-muted\"><a href=\"#{anchor}\"><img class=\"feature-icon-small\" src=\"img/modules/{module.Name}.png\"/>{module.Name}</a> – {description}</p>");

                result.AppendLine($"<div class=\"row\"><div class=\"col-lg-12\"><a class=\"anchor\" id=\"{anchor}\"></a><h3><img class=\"feature-icon-big\" src=\"img/modules/{module.Name}.png\"/>{module.Name}</h3>");
                result.AppendLine($"<p class=\"text-muted\">{description}</p>");

                foreach (var handledCommand in module.Commands.Where(x => !x.Flags.HasFlag(CommandFlags.Hidden) && !x.Flags.HasFlag(CommandFlags.OwnerOnly)))
                {
                    counter++;

                    if (handledCommand.PrimaryUsage.InvokeUsage == "calendar create")
                    {
                        result.AppendLine("</br><p class=\"text-muted\">Calendars are automatically updated messages which display parts of the schedule.</p>");
                    }
                    else if (handledCommand.PrimaryUsage.InvokeUsage == "roles group add")
                    {
                        result.AppendLine("</br><p class=\"text-muted\">Use groups to limit the number of roles a user may have.</p>");
                    }
                    else if (handledCommand.PrimaryUsage.InvokeUsage == "event add")
                    {
                        result.AppendLine("</br><p class=\"text-muted\">Events are the content of your schedule.</p>");
                    }

                    result.AppendLine($"<p data-target=\"#usage{counter}\" data-toggle=\"collapse\" class=\"paramlistitem\">" +
                                      $"<i class=\"fa fa-angle-right\" style=\"margin-right: 3px;\"></i><span class=\"paramlistcode\">{handledCommand.PrimaryUsage.InvokeUsage}</span> – {handledCommand.Description} " +
                                      "</p>");

                    var usage = BuildWebUsageString(handledCommand, _botOptions.Value.DefaultCommandPrefix);
                    if (string.IsNullOrEmpty(usage))
                    {
                        continue;
                    }

                    result.AppendLine($"<div id=\"usage{counter}\" class=\"collapse usage\">");
                    result.Append(usage);
                    result.AppendLine("</div>");
                }

                result.AppendLine("<br/></div></div>");
            }

            preface.AppendLine("</div></div>");
            preface.AppendLine("<hr/>");
            preface.Append(result);
            using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(preface.ToString())))
            {
                await command.Message.Channel.SendFileAsync(stream, "output.html");
            }
        }
Пример #2
0
 public string GetModuleWebLink(string name) =>
 DiscordHelpers.SanitiseMarkdownUri(_websiteWalker.ReferenceUrl + "#" + WebsiteWalker.GetModuleWebAnchor(name));