Example #1
0
        public Discord.Embed GenerateEmbed()
        {
            JEmbed emb = new JEmbed();

            emb.Author.Name = "POLL";
            emb.ColorStripe = Constants.Colours.YORK_RED;
            emb.Description = question;

            char letter = 'a';

            foreach (string o in options)
            {
                emb.Description += $"\n:regional_indicator_{letter}:: {o} - [{votes[Char.ToLower(letter) - 'a']} votes]";
                letter++;
            }

            if (!completed)
            {
                emb.Footer.Text = "Vote with ;poll vote [choice]!";
            }
            else
            {
                emb.Footer.Text = "Poll completed.";
            }
            return(emb.Build());
        }
Example #2
0
        public async Task Course([Remainder] string code)
        {
            if (code.Count() == 8 && int.TryParse(code.Substring(4), out int output))
            {
                code = code.Substring(0, 4) + " " + code.Substring(4);
            }


            string  searchLink = "http://www.google.com/search?q=w2prod " + code;
            HtmlWeb web = new HtmlWeb();
            bool    found = false;
            string  desc, title;
            int     searchIndex = 0;

            do
            {
                var page  = web.Load(searchLink);
                var html  = page.ParsedText;
                var index = html.IndexOf("<h3 class=\"r\">", searchIndex);
                searchIndex = index + 20;
                int start = 0, end = 0;

                //make better

                for (int i = index; i < html.Count(); i++)
                {
                    if (html.Substring(i, 2) == "q=")
                    {
                        start = i + 2;
                        for (int o = start; o < html.Count(); o++)
                        {
                            if (html[o] == '&')
                            {
                                end = o;
                                break;
                            }
                        }
                        break;
                    }
                }
                string newLink = "";
                newLink = html.Substring(start, end - start).Replace("%3F", "?").Replace("%3D", "=").Replace("%26", "&");
                page    = web.Load(newLink);
                desc    = page.DocumentNode.SelectSingleNode("/html[1]/body[1]/table[1]/tr[2]/td[2]/table[1]/tr[2]/td[1]/table[1]/tr[1]/td[1]").ChildNodes[5].InnerText;
                title   = page.DocumentNode.SelectSingleNode("/html[1]/body[1]/table[1]/tr[2]/td[2]/table[1]/tr[2]/td[1]/table[1]/tr[1]/td[1]/table[1]/tr[1]/td[1]").InnerText.Replace("&nbsp;", "");

                if (title.ToLower().Contains(code.ToLower()))
                {
                    found = true;
                }
            } while (!found);

            JEmbed emb = new JEmbed();

            emb.Title       = title;
            emb.Description = desc;
            emb.ColorStripe = Constants.Colours.YORK_RED;

            await Context.Channel.SendMessageAsync("", embed : emb.Build());
        }
Example #3
0
        public async Task Define([Remainder] string word)
        {
            OxfordDictionaryClient client = new OxfordDictionaryClient("45278ea9", "c4dcdf7c03df65ac5791b67874d956ce");
            var result = await client.SearchEntries(word, CancellationToken.None);

            if (result != null)
            {
                var senses = result.Results[0].LexicalEntries[0].Entries[0].Senses[0];

                JEmbed emb = new JEmbed();
                emb.Title       = Func.ToTitleCase(word);
                emb.Description = Char.ToUpper(senses.Definitions[0][0]) + senses.Definitions[0].Substring(1) + ".";
                emb.ColorStripe = Constants.Colours.YORK_RED;
                if (senses.Examples != null)
                {
                    emb.Fields.Add(new JEmbedField(x =>
                    {
                        x.Header    = "Examples:";
                        string text = "";
                        foreach (OxfordDictionariesAPI.Models.Example eg in senses.Examples)
                        {
                            text += $"\"{Char.ToUpper(eg.Text[0]) + eg.Text.Substring(1)}.\"\n";
                        }
                        x.Text = text;
                    }));
                }
                await Context.Channel.SendMessageAsync("", embed : emb.Build());
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Could not find definition for: {word}.");
            }
        }
Example #4
0
 public InfoEmbed(string title, string msg, string image = Constants.Images.ForkBot)
 {
     emb = new JEmbed
     {
         Description  = msg,
         ColorStripe  = Constants.Colours.YORK_RED,
         Title        = title,
         ThumbnailUrl = image
     };
 }
Example #5
0
        public async Task HandleDelete(Cacheable <IMessage, ulong> cache, ISocketMessageChannel channel)
        {
            var msg = cache.Value;
            var id  = (msg.Author as IGuildUser).Guild.Id;

            if ((id == Constants.Guilds.BASSIC || id == Constants.Guilds.YORK_UNIVERSITY) & msg.Author.Id != client.CurrentUser.Id && !Var.purging && msg.Content != ";bomb")
            {
                JEmbed emb = new JEmbed();
                emb.Title        = msg.Author.Username + "#" + msg.Author.Discriminator;
                emb.Author.Name  = "MESSAGE DELETED";
                emb.ThumbnailUrl = msg.Author.GetAvatarUrl();
                emb.Description  = msg.Content;

                string attachURL = null;
                if (msg.Attachments.Count > 0)
                {
                    attachURL = msg.Attachments.FirstOrDefault().ProxyUrl;
                }
                if (attachURL != null)
                {
                    emb.ImageUrl = attachURL;
                }

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "Location";
                    x.Text   = msg.Channel + " in " + (msg.Channel as IGuildChannel).Guild;
                    x.Inline = true;
                }));

                emb.ColorStripe = Constants.Colours.YORK_RED;
                var datetime = DateTime.UtcNow - new TimeSpan(5, 0, 0);
                emb.Footer.Text = datetime.ToLongDateString() + " " + datetime.ToLongTimeString() + " | " +
                                  msg.Author.Username + "#" + msg.Author.Discriminator + " ID: " + msg.Author.Id;

                ulong msgChan = 0;

                if (id == Constants.Guilds.YORK_UNIVERSITY)
                {
                    msgChan = Constants.Channels.DELETED_MESSAGES;
                }
                else
                {
                    msgChan = Constants.Channels.ASS_DELETED_MESSAGES;
                }

                var chan = client.GetChannel(msgChan) as IMessageChannel;
                await chan.SendMessageAsync("", embed : emb.Build());
            }
        }
Example #6
0
        /// <summary>
        /// Generates the embed menu to display the trade info.
        /// </summary>
        /// <returns></returns>
        public Embed CreateMenu()
        {
            JEmbed emb    = new JEmbed();
            string u1Name = Bot.client.GetUser(u1.ID).Username;
            string u2Name = Bot.client.GetUser(u2.ID).Username;

            emb.Title       = $"Trade: {u1Name} - {u2Name}";
            emb.Description = "Use `;trade add [item]` to add an item, or `;trade add [number]` to add coins.\nWhen done, use `;trade finish` or use `;trade cancel` to cancel the trade.\nYou can now put `*[#]` at the end to add multiple items! (i.e. `;trade add key*10`)";

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Header = u1Name + "'s Items";

                string itemlist = "";
                foreach (string item in items1)
                {
                    itemlist += DBFunctions.GetItemEmote(item);
                }
                if (coins1 > 0)
                {
                    itemlist += ":moneybag:" + coins1 + " coins";
                }

                x.Text   = itemlist;
                x.Inline = true;
            }));
            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Header = u2Name + "'s Items";

                string itemlist = "";
                foreach (string item in items2)
                {
                    itemlist += DBFunctions.GetItemEmote(item);
                }
                if (coins2 > 0)
                {
                    itemlist += ":moneybag:" + coins2 + " coins";
                }

                x.Text   = itemlist;
                x.Inline = true;
            }));

            emb.ColorStripe    = Constants.Colours.YORK_RED;
            emb.Author.IconUrl = Constants.Images.ForkBot;
            emb.Author.Name    = "Forkbot Trade Menu:tm:";

            return(emb.Build());
        }
Example #7
0
        /// <summary>
        /// Generates the embed menu to display the trade info.
        /// </summary>
        /// <returns></returns>
        public Embed CreateMenu()
        {
            JEmbed emb = new JEmbed();

            emb.Title       = $"Trade: {u1.Username()} - {u2.Username()}";
            emb.Description = "Use `;trade add [item]` to add an item, or `;trade add [number]` to add coins.\nWhen done, use `;trade finish` or use `;trade cancel` to cancel the trade.";

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Header = u1.Username() + "'s Items";

                string itemlist = "";
                foreach (string item in items1)
                {
                    itemlist += ":" + item + ": ";
                }
                if (coins1 > 0)
                {
                    itemlist += coins1 + " coins";
                }

                x.Text   = itemlist;
                x.Inline = true;
            }));
            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Header = u2.Username() + "'s Items";

                string itemlist = "";
                foreach (string item in items2)
                {
                    itemlist += ":" + item + ": ";
                }
                if (coins2 > 0)
                {
                    itemlist += coins2 + " coins";
                }

                x.Text   = itemlist;
                x.Inline = true;
            }));

            emb.ColorStripe    = Constants.Colours.YORK_RED;
            emb.Author.IconUrl = Constants.Images.ForkBot;
            emb.Author.Name    = "Forkbot Trade Menu";

            return(emb.Build());
        }
Example #8
0
        public async Task Profile(IUser user)
        {
            var u = Functions.GetUser(user);

            var emb = new JEmbed();

            emb.Author.Name    = user.Username;
            emb.Author.IconUrl = user.GetAvatarUrl();

            emb.ColorStripe = Functions.GetColor(user);

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Header = "Coins:";
                x.Text   = Convert.ToString(u.Coins);
                x.Inline = true;
            }));

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Header    = "Roles:";
                string text = "";
                foreach (ulong id in (user as IGuildUser).RoleIds)
                {
                    text += Context.Guild.GetRole(id).Name + "\n";
                }

                x.Text   = Convert.ToString(text);
                x.Inline = true;
            }));

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Header    = "Inventory:";
                string text = "";
                foreach (string item in u.Items)
                {
                    text += item + ", ";
                }
                x.Text = Convert.ToString(text);
            }));

            await Context.Channel.SendMessageAsync("", embed : emb.Build());
        }
Example #9
0
        public async Task WhatIs([Remainder] string thing)
        {
            var         results = new Search().Query(thing, "ForkBot");
            QueryResult result  = null;

            if (results.Abstract == "" && results.RelatedTopics.Count > 0)
            {
                result = results.RelatedTopics[0];
            }

            if (result != null)
            {
                JEmbed emb = new JEmbed();
                emb.Title       = thing;
                emb.Description = result.Text;
                emb.ImageUrl    = result.Icon.Url;
                await Context.Channel.SendMessageAsync("", embed : emb.Build());
            }
            else
            {
                await Context.Channel.SendMessageAsync("No results found!");
            }
        }
Example #10
0
        public async Task HandleReact(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel, SocketReaction react)
        {
            if ((react.UserId != client.CurrentUser.Id))
            {
                string tag = null;
                Discord.Rest.RestUserMessage message = null;
                foreach (IMessage msg in Var.awaitingHelp)
                {
                    if (msg.Id == cache.Value.Id)
                    {
                        if (react.Emote.Name == Constants.Emotes.HAMMER.Name)
                        {
                            tag = "[MOD]";
                        }
                        else if (react.Emote.Name == Constants.Emotes.DIE.Name)
                        {
                            tag = "[FUN]";
                        }
                        else if (react.Emote.Name == Constants.Emotes.QUESTION.Name)
                        {
                            tag = "[OTHER]";
                        }
                        else if (react.Emote.Name == Constants.Emotes.BRADY.Name)
                        {
                            tag = "[BRADY]";
                        }
                        message = msg as Discord.Rest.RestUserMessage;
                        Var.awaitingHelp.Remove(msg);
                        break;
                    }
                }

                if (tag != null)
                {
                    JEmbed emb = new JEmbed();

                    emb.Author.Name = "ForkBot Commands";
                    emb.ColorStripe = Constants.Colours.DEFAULT_COLOUR;

                    foreach (CommandInfo c in commands.Commands)
                    {
                        string cTag = null;
                        if (c.Summary != null)
                        {
                            if (c.Summary.StartsWith("["))
                            {
                                int index;
                                index = c.Summary.IndexOf(']') + 1;
                                cTag  = c.Summary.Substring(0, index);
                            }
                            else
                            {
                                cTag = "[OTHER]";
                            }
                        }


                        if (cTag != null && cTag == tag)
                        {
                            emb.Fields.Add(new JEmbedField(x =>
                            {
                                string header = c.Name;
                                foreach (String alias in c.Aliases)
                                {
                                    if (alias != c.Name)
                                    {
                                        header += " (;" + alias + ") ";
                                    }
                                }
                                foreach (Discord.Commands.ParameterInfo parameter in c.Parameters)
                                {
                                    header += " [" + parameter.Name + "]";
                                }
                                x.Header = header;
                                x.Text   = c.Summary.Replace(tag + " ", "");
                            }));
                        }
                    }
                    await message.ModifyAsync(x => x.Embed = emb.Build());

                    await message.RemoveAllReactionsAsync();
                }
            }
        }
Example #11
0
        public async Task HandleEdit(Cacheable <IMessage, ulong> cache, SocketMessage msg, ISocketMessageChannel channel)
        {
            if (msg.Content == cache.Value.Content)
            {
                return;
            }
            if ((msg.Channel as IGuildChannel).Guild.Id == Constants.Guilds.YORK_UNIVERSITY && Functions.Filter(msg.Content))
            {
                await msg.DeleteAsync();

                return;
            }

            if ((msg.Author as IGuildUser).Guild.Id == Constants.Guilds.YORK_UNIVERSITY && msg.Author.Id != client.CurrentUser.Id && !Var.purging)
            {
                JEmbed emb = new JEmbed();
                emb.Title        = msg.Author.Username + "#" + msg.Author.Discriminator;
                emb.Author.Name  = "MESSAGE EDITED";
                emb.ThumbnailUrl = msg.Author.GetAvatarUrl();

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "ORIGINAL:";
                    x.Text   = cache.Value.Content;
                    x.Inline = true;
                }));

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "EDITED:";
                    x.Text   = msg.Content;
                    x.Inline = true;
                }));

                string attachURL = null;
                if (msg.Attachments.Count > 0)
                {
                    attachURL = msg.Attachments.FirstOrDefault().ProxyUrl;
                }
                if (attachURL != null)
                {
                    emb.ImageUrl = attachURL;
                }

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "Location";
                    x.Text   = msg.Channel + " in " + (msg.Channel as IGuildChannel).Guild;
                    x.Inline = false;
                }));

                emb.ColorStripe = Constants.Colours.TWITTER_BLUE;
                var datetime = DateTime.UtcNow - new TimeSpan(5, 0, 0);
                emb.Footer.Text = datetime.ToLongDateString() + " " + datetime.ToLongTimeString() + " | " +
                                  msg.Author.Username + "#" + msg.Author.Discriminator + " ID: " + msg.Author.Id;


                var chan = client.GetChannel(Constants.Channels.DELETED_MESSAGES) as IMessageChannel;
                await chan.SendMessageAsync("", embed : emb.Build());
            }
        }
Example #12
0
        public async Task HandleCommand(SocketMessage messageParam)
        {
            var message = messageParam as SocketUserMessage;

            if (message == null)
            {
                return;
            }
            int argPos = 0;

            if (Var.blockedUsers.Contains(message.Author))
            {
                return;
            }

            var user = Functions.GetUser(message.Author);

            if (Var.recieving)
            {
                if (message.Channel == Var.recievingChannel)
                {
                    var bBunch = client.GetGuild(371695008157532160).GetChannel(381656424247197697) as IMessageChannel;

                    JEmbed emb = new JEmbed();
                    emb.Title        = message.Author.Username + "#" + message.Author.Discriminator;
                    emb.Author.Name  = "MESSAGE RECIEVED";
                    emb.ThumbnailUrl = message.Author.GetAvatarUrl();
                    emb.Description  = message.Content;

                    string attachURL = null;
                    if (message.Attachments.Count > 0)
                    {
                        attachURL = message.Attachments.FirstOrDefault().ProxyUrl;
                    }
                    if (attachURL != null)
                    {
                        emb.ImageUrl = attachURL;
                    }

                    await bBunch.SendMessageAsync("", embed : emb.Build());
                }
            }

            if (message.HasCharPrefix(';', ref argPos))
            {
                var context = new CommandContext(client, message);
                var result  = await commands.ExecuteAsync(context, argPos);

                if (!result.IsSuccess)
                {
                    if (result.Error != CommandError.UnknownCommand)
                    {
                        Console.WriteLine(result.ErrorReason);
                        var emb = new InfoEmbed("ERROR:", result.ErrorReason).Build();
                        await message.Channel.SendMessageAsync("", embed : emb);
                    }
                }
            }
            else
            {
                return;
            }
        }
Example #13
0
        public async Task Shop(string command = null)
        {
            var      u          = Functions.GetUser(Context.User);
            DateTime day        = new DateTime();
            DateTime currentDay = new DateTime();

            if (Var.currentShop != null)
            {
                day        = Var.currentShop.Date();
                currentDay = DateTime.UtcNow - new TimeSpan(5, 0, 0);
            }
            if (Var.currentShop == null || day.DayOfYear < currentDay.DayOfYear && day.Year == currentDay.Year)
            {
                var nItems   = Functions.GetItemList();
                var rItems   = Functions.GetRareItemList();
                var allItems = nItems.Concat(rItems).ToArray();

                List <string> items = new List <string>();
                for (int i = 0; i < 5; i++)
                {
                    int itemID = rdm.Next(allItems.Length);
                    if (!items.Contains(allItems[itemID]))
                    {
                        items.Add(allItems[itemID]);
                    }
                    else
                    {
                        i--;
                    }
                }

                Var.currentShop = new Shop(items);
            }

            List <string> itemNames = new List <string>();

            foreach (string item in Var.currentShop.Items())
            {
                itemNames.Add(item.Split('|')[0]);
            }



            if (command == null)
            {
                JEmbed emb = new JEmbed();
                emb.Title        = "Shop";
                emb.ThumbnailUrl = Constants.Images.ForkBot;
                emb.ColorStripe  = Constants.Colours.YORK_RED;
                foreach (string item in Var.currentShop.Items())
                {
                    var    data  = item.Split('|');
                    string name  = data[0];
                    string desc  = data[1];
                    int    price = Convert.ToInt32(data[2]) * 2;
                    if (price < 0)
                    {
                        price *= -1;
                    }
                    emb.Fields.Add(new JEmbedField(x =>
                    {
                        x.Header = $":{name}: {name} - {price} coins";
                        x.Text   = desc;
                    }));
                }
                await Context.Channel.SendMessageAsync("", embed : emb.Build());
            }
            else if (itemNames.Contains(command.ToLower()))
            {
                foreach (string item in Var.currentShop.Items())
                {
                    if (item.Split('|')[0] == command.ToLower())
                    {
                        var    data  = item.Split('|');
                        string name  = data[0];
                        string desc  = data[1];
                        int    price = Convert.ToInt32(data[2]) * 2;
                        if (price < 0)
                        {
                            price *= -1;
                        }

                        if (u.Coins >= price)
                        {
                            u.Coins -= price;
                            u.Items.Add(name);
                            Functions.SaveUsers();
                            await Context.Channel.SendMessageAsync($":shopping_cart: You have successfully purchased a(n) {name} :{name}: for {price} coins!");
                        }
                        else
                        {
                            await Context.Channel.SendMessageAsync("You cannot afford this item.");
                        }
                    }
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync("Either something went wrong, or this item isn't in stock!");
            }
        }
Example #14
0
        public async Task Professor([Remainder] string name)
        {
            HtmlWeb web = new HtmlWeb();

            string link = "http://www.ratemyprofessors.com/search.jsp?query=" + name.Replace(" ", "%20");
            var    page = web.Load(link);
            var    node = page.DocumentNode.SelectSingleNode("//*[@id=\"searchResultsBox\"]/div[2]/ul/li[1]");

            if (node != null)
            {
                string tid = Functions.GetTID(node.InnerHtml);

                var newLink = "http://www.ratemyprofessors.com/ShowRatings.jsp?tid=" + tid;
                page = web.Load(newLink);

                var    rating     = page.DocumentNode.SelectSingleNode("//*[@id=\"mainContent\"]/div[1]/div[3]/div[1]/div/div[1]/div/div/div").InnerText;
                var    takeAgain  = page.DocumentNode.SelectSingleNode("//*[@id=\"mainContent\"]/div[1]/div[3]/div[1]/div/div[2]/div[1]/div").InnerText;
                var    difficulty = page.DocumentNode.SelectSingleNode("//*[@id=\"mainContent\"]/div[1]/div[3]/div[1]/div/div[2]/div[2]/div").InnerText;
                var    imageNode  = page.DocumentNode.SelectSingleNode("//*[@id=\"mainContent\"]/div[1]/div[1]/div[2]/div[1]/div[1]/img");
                var    titleText  = page.DocumentNode.SelectSingleNode("/html/head/title").InnerText;
                string profName   = titleText.Split(' ')[0] + " " + titleText.Split(' ')[1];

                var           tagsNode = page.DocumentNode.SelectSingleNode("//*[@id=\"mainContent\"]/div[1]/div[3]/div[2]/div[2]");
                List <string> tags     = new List <string>();
                for (int i = 0; i < tagsNode.ChildNodes.Count(); i++)
                {
                    if (tagsNode.ChildNodes[i].Name == "span")
                    {
                        tags.Add(tagsNode.ChildNodes[i].InnerText);
                    }
                }

                var    hotness    = page.DocumentNode.SelectSingleNode("//*[@id=\"mainContent\"]/div[1]/div[3]/div[1]/div/div[2]/div[3]/div/figure/img").Attributes[0].Value;
                var    hotnessIMG = "http://www.ratemyprofessors.com" + hotness;
                string imageURL   = null;
                if (imageNode != null)
                {
                    imageURL = imageNode.Attributes[0].Value;
                }

                var commentsNode = page.DocumentNode.SelectSingleNode("/ html[1] / body[1] / div[2] / div[4] / div[3] / div[1] / div[7] / table[1]");

                List <string> comments = new List <string>();
                for (int i = 3; i < commentsNode.ChildNodes.Count(); i++)
                {
                    if (commentsNode.ChildNodes[i].Name == "tr" && commentsNode.ChildNodes[i].Attributes.Count() == 2)
                    {
                        comments.Add(commentsNode.ChildNodes[i].ChildNodes[5].ChildNodes[3].InnerText.Replace("\r\n               ", "").Replace("/", " "));
                    }
                }
                List <string> words  = new List <string>();
                List <int>    counts = new List <int>();

                foreach (string comment in comments)
                {
                    foreach (string dWord in comment.Split(' '))
                    {
                        string word = dWord.ToLower().Replace(".", "").Replace(",", "").Replace("'", "").Replace("(", "").Replace(")", "").Replace("!", "").Replace("?", "");
                        if (word != "")
                        {
                            if (words.Contains(word))
                            {
                                counts[words.IndexOf(word)]++;
                            }
                            else
                            {
                                words.Add(word);
                                counts.Add(1);
                            }
                        }
                    }
                }

                List <string> OrderedWords = new List <string>();
                for (int i = counts.Max(); i >= 0; i--)
                {
                    for (int c = 0; c < counts.Count(); c++)
                    {
                        if (counts[c] == i)
                        {
                            OrderedWords.Add(words[counts.IndexOf(counts[c])]);
                            break;
                        }
                    }
                }
                string[] commonWords = { "youll", "if", "an", "not", "it", "as", "is", "in", "for", "but", "so", "on", "he", "the", "and", "to", "a", "are", "his", "she", "her", "you", "of", "hes", "shes", "prof", profName.ToLower().Split(' ')[0], profName.ToLower().Split(' ')[1] };
                foreach (string wrd in commonWords)
                {
                    OrderedWords.Remove(wrd);
                }

                JEmbed emb = new JEmbed();

                emb.Title = profName;
                if (imageURL != null)
                {
                    emb.ImageUrl = imageURL;
                }
                emb.ThumbnailUrl = hotnessIMG;
                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "Rating:";
                    x.Text   = rating;
                    x.Inline = true;
                }));

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "Difficulty:";
                    x.Text   = difficulty;
                    x.Inline = true;
                }));

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "Would take again?:";
                    x.Text   = takeAgain;
                    x.Inline = true;
                }));

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header    = "Top Tags:";
                    string text = "";
                    foreach (string s in tags)
                    {
                        text += s;
                    }
                    x.Text   = text;
                    x.Inline = false;
                }));

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header    = "Common Comments:";
                    string text = "";
                    foreach (string s in OrderedWords)
                    {
                        text += Func.ToTitleCase(s) + ", ";
                    }
                    text     = text.Substring(0, text.Count() - 2);
                    x.Text   = text;
                    x.Inline = false;
                }));

                emb.ColorStripe = Constants.Colours.YORK_RED;
                await Context.Channel.SendMessageAsync("", embed : emb.Build());
            }
            else
            {
                await Context.Channel.SendMessageAsync("Professor not found!");
            }
        }
Example #15
0
        public async Task Help()
        {
            JEmbed emb = new JEmbed();

            emb.Author.Name  = "ForkBot Commands";
            emb.ThumbnailUrl = Context.User.AvatarId;
            if (Context.Guild != null)
            {
                emb.ColorStripe = Functions.GetColor(Context.User);
            }
            else
            {
                emb.ColorStripe = Constants.Colours.DEFAULT_COLOUR;
            }

            emb.Description = "Select the emote that corresponds to the commands you want to see.";

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Text   = ":hammer:";
                x.Header = "MOD COMMANDS";
                x.Inline = true;
            }));

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Text   = ":game_die:";
                x.Header = "FUN COMMANDS";
                x.Inline = true;
            }));

            emb.Fields.Add(new JEmbedField(x =>
            {
                x.Text   = ":question:";
                x.Header = "OTHER COMMANDS";
                x.Inline = true;
            }));



            var msg = await Context.Channel.SendMessageAsync("", embed : emb.Build());

            await msg.AddReactionAsync(Constants.Emotes.hammer);

            await msg.AddReactionAsync(Constants.Emotes.die);

            await msg.AddReactionAsync(Constants.Emotes.question);

            Var.awaitingHelp.Add(msg);

            /*
             *  foreach (CommandInfo command in Bot.commands.Commands)
             *  {
             *
             *
             *      if (command.Summary != null && !command.Summary.StartsWith("[MOD]")) {
             *          emb.Fields.Add(new JEmbedField(x =>
             *          {
             *              string header = command.Name;
             *              foreach (String alias in command.Aliases) if (alias != command.Name) header += " (;" + alias + ") ";
             *              foreach (ParameterInfo parameter in command.Parameters) header += " [" + parameter.Name + "]";
             *              x.Header = header;
             *              x.Text = command.Summary;
             *          }));
             *      }
             *  }
             *  await Context.Channel.SendMessageAsync("", embed: emb.Build());
             */
        }
Example #16
0
        public JEmbed Build()
        {
            JEmbed emb = new JEmbed();

            if (!isBM)
            {
                emb.Title = "Shop";
            }
            else
            {
                emb.Title = ":spy: Black Market :spy:";
            }
            emb.ThumbnailUrl = Constants.Images.ForkBot;
            emb.ColorStripe  = Constants.Colours.YORK_RED;
            var restock = new TimeSpan(4, 0, 0).Add(openDate - Var.CurrentDate());

            if (!isBM)
            {
                emb.Description = $"The shop will restock in {restock.Hours} hours and {restock.Minutes} minutes.";
            }
            else
            {
                emb.Description = $"Welcome to the Black Market... Buy somethin and get out. We'll restock in {restock.Hours} hours and {restock.Minutes} minutes.";
            }
            for (int i = 0; i < 5; i++)
            {
                var    itemID = items[i];
                string emote  = DBFunctions.GetItemEmote(items[i]);
                string name   = DBFunctions.GetItemName(itemID);
                string desc;
                desc = DBFunctions.GetItemDescription(itemID, isBM);
                int stockAmt = stock[i];
                int price    = DBFunctions.GetItemPrice(itemID);
                if (price < 0)
                {
                    price = -price;
                }
                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = $"{emote} {name.Replace("_", " ")} - {price} coins [{stockAmt} left in stock]";
                    x.Text   = desc;
                }));
            }

            if (!isBM)
            {
                var count = DBFunctions.GetRelevantNewsCount();

                if (count > 0)
                {
                    emb.Fields.Add(new JEmbedField(x =>
                    {
                        var newsPrice = DBFunctions.GetItemPrice("newspaper");
                        x.Header      = $"📰 Newspaper -  { newsPrice } [({count}) current article(s)]";
                        x.Text        = "The Daily Fork! Get all the now information of what's going on around ForkBot!";
                    }));
                }
            }

            return(emb);
        }