Exemplo n.º 1
0
        /// <summary>
        /// Gets a column for a page
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public DiscordEmbedField GetColumnForPage(string title, int page)
        {
            if (page <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(page));
            }
            else if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentNullException(nameof(title));
            }

            lock (SyncRoot)
            {
                if (!_fields.ContainsKey(title))
                {
                    return(null);
                }

                EmbedFieldInfo efi    = _fields[title];
                string         column = efi.ToString((page - 1) * 10, 10);


                Type et = typeof(DiscordEmbedField);
                ConstructorInfo[] constructors = et.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance);
                ConstructorInfo   constructor  = constructors[0];

                DiscordEmbedField def = (DiscordEmbedField)constructor.Invoke(null);
                def.Name   = title;
                def.Value  = column;
                def.Inline = true;

                return(def);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the amount of pages in total
        /// </summary>
        public int GetMaxPages()
        {
            lock (SyncRoot)
            {
                EmbedFieldInfo efi = _fields.Values.ElementAt(0);

                double pagesD = efi.Count / 10.0;
                int    pages  = (int)pagesD;

                if (pages < pagesD)
                {
                    pages++;
                }

                return(pages);
            }
        }