Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get some images and shite
- [Command("image", RunMode = RunMode.Async)]
- [Summary("Gets images from a search result")]
- public async Task ImagesAsync([Remainder] [Summary("Search Input")] string searchInput)
- {
- var imageSearch = new EmbedBuilder();
- var footerImages = new EmbedFooterBuilder();
- var sutImages = new WikiSearch(domainUrl);
- List<string> titles = new List<string>();
- LocalWikiSearchResultSet resultSearch;
- SearchListRequestParameter requestParametersSearch = new SearchListRequestParameter(searchInput);
- requestParametersSearch.Limit = 30;
- requestParametersSearch.Batch = 1;
- requestParametersSearch.Namespaces = new HashSet<string>{"6", "7"};
- requestParametersSearch.MinArticleQuality = 0;
- var wikiArticleDetails = new WikiArticle(domainUrl);
- // do the search
- resultSearch = await sutImages.SearchList(requestParametersSearch);
- for (int i = 0; i < resultSearch.Items.Count(); i++)
- {
- if (!resultSearch.Items[i].Title.Equals(null))
- titles.Add(resultSearch.Items[i].Title);
- }
- int iteration = 0;
- var messageSent = await Context.Channel.SendMessageAsync("Tiphereth B: \"Does this name sound right?\" `" + titles[iteration] + "`");
- Emoji yes = new Emoji("👍");
- Emoji no = new Emoji("👎");
- await messageSent.AddReactionAsync(yes);
- await messageSent.AddReactionAsync(no);
- string finalImage;
- // wait for the user inputer
- /* TODO: Figure out what's wrong with this */
- while (true)
- {
- var usersReactedYes = await messageSent.GetReactionUsersAsync("👍");
- var usersReactedNo = await messageSent.GetReactionUsersAsync("👎");
- if (usersReactedYes.Contains(Context.User))
- {
- await messageSent.RemoveAllReactionsAsync();
- await Context.Channel.SendMessageAsync("Tiphereth B: \"Here you go!\"");
- var detailsResult = await wikiArticleDetails.Details(Int32.Parse(resultSearch.Items[iteration].Id));
- finalImage = detailsResult.Items[resultSearch.Items[iteration].Id].Thumbnail.Remove(detailsResult.Items[resultSearch.Items[iteration].Id].Thumbnail.IndexOf("/revision") + 1);
- await Context.Channel.SendMessageAsync(finalImage);
- break;
- }
- else if (usersReactedNo.Contains(Context.User))
- {
- await messageSent.DeleteAsync();
- messageSent = await Context.Channel.SendMessageAsync("Tiphereth B: \"What about this one?\" `" + titles[iteration] + "`");
- await messageSent.AddReactionAsync(new Emoji ("👍"));
- await messageSent.AddReactionAsync(new Emoji("👎"));
- iteration++;
- }
- }
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " " + Context.User + " Image: " + searchInput);
- Console.ResetColor();
- }
- //NOTE: This is broken right now lmao
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement