/// <summary> /// Builds a set of pre-formatted pages for the commands in the given module. /// </summary> /// <param name="module">The module that contains the commands.</param> /// <returns>A list of pages, where each page is a list of embed fields.</returns> private IReadOnlyList <IReadOnlyList <EmbedFieldBuilder> > BuildCommandListPages([NotNull] ModuleInfo module) { var pages = new List <IReadOnlyList <EmbedFieldBuilder> >(); var currentPage = new List <EmbedFieldBuilder>(); var currentContentLength = 0; var commandGroups = module .GetAllCommands() .GroupBy(c => c.Aliases.OrderByDescending(a => a).First()) .ToList(); foreach (var commandGroup in commandGroups) { var helpField = _help.CreateCommandInfoEmbedField(commandGroup.First()); var commandContentLength = helpField.Name.Length + ((string)helpField.Value).Length; if (commandGroup.Count() > 1) { var hint = "*This command has multiple variants.*"; helpField.WithValue((string)helpField.Value + "\n" + hint); commandContentLength += hint.Length; } if (currentPage.Count >= 5 || (currentContentLength + commandContentLength) > 1300) { pages.Add(currentPage); currentPage = new List <EmbedFieldBuilder>(); currentContentLength = 0; } currentPage.Add(helpField); currentContentLength += commandContentLength; if (commandGroup == commandGroups.Last() && !pages.Contains(currentPage)) { pages.Add(currentPage); } } return(pages); }