Exemplo n.º 1
0
        /// <summary>
        /// Returns the gelp file as a node object
        /// </summary>
        /// <param name="path">Path to the help file</param>
        /// <returns>The node corresponding to the file</returns>
        public static HelpPageNode GetNode(string path)
        {
            string json = FileManager.ReadFullFile(path);

            HelpPageNode help = JsonConvert.DeserializeObject <HelpPageNode>(json);

            return(help);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Takes in the embed builder and adds the formatted help page.
        /// </summary>
        /// <param name="eb">The embed builder</param>
        private void AddHelpPage(EmbedBuilder eb)
        {
            if (BotUtils.GetFileExtension(Path) == "json")
            {
                // Interpret JSON
                HelpPageNode page = HelpManager.GetNode(Path);

                eb.AddField("Command Name", $"{page.Name}");

                if (page.Alias.Length > 0)
                {
                    string alias = "!" + page.Alias[0];

                    for (int i = 1; i < page.Alias.Length; i++)
                    {
                        alias += $", !{page.Alias[i]}";
                    }

                    eb.AddField("Aliases", alias);
                }

                eb.AddField("Usage", page.Usage);
                eb.AddField("Description", page.Description);

                if (!string.IsNullOrWhiteSpace(page.GifURL))
                {
                    eb.AddField("Example:", BotUtils.ZeroSpace);
                    eb.WithImageUrl(page.GifURL);
                }
            }
            else
            {
                // Assume it's text. All other files are ignored anyways
                string text = FileManager.ReadFullFile(Path);
                eb.AddField(BotUtils.ZeroSpace, text);
            }
        }