Advertisement
Guest User

Watson's probably cursed code that shouldn't exist

a guest
Jan 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.14 KB | None | 0 0
  1. // Get some images and shite
  2.     [Command("image", RunMode = RunMode.Async)]
  3.     [Summary("Gets images from a search result")]
  4.     public async Task ImagesAsync([Remainder] [Summary("Search Input")] string searchInput)
  5.     {
  6.         var imageSearch = new EmbedBuilder();
  7.         var footerImages = new EmbedFooterBuilder();
  8.         var sutImages = new WikiSearch(domainUrl);
  9.  
  10.         List<string> titles = new List<string>();
  11.         LocalWikiSearchResultSet resultSearch;
  12.  
  13.         SearchListRequestParameter requestParametersSearch = new SearchListRequestParameter(searchInput);
  14.         requestParametersSearch.Limit = 30;
  15.         requestParametersSearch.Batch = 1;
  16.         requestParametersSearch.Namespaces = new HashSet<string>{"6", "7"};
  17.         requestParametersSearch.MinArticleQuality = 0;
  18.  
  19.         var wikiArticleDetails = new WikiArticle(domainUrl);
  20.         // do the search
  21.         resultSearch = await sutImages.SearchList(requestParametersSearch);
  22.         for (int i = 0; i < resultSearch.Items.Count(); i++)
  23.         {
  24.             if (!resultSearch.Items[i].Title.Equals(null))
  25.                 titles.Add(resultSearch.Items[i].Title);
  26.         }
  27.         int iteration = 0;
  28.         var messageSent = await Context.Channel.SendMessageAsync("Tiphereth B: \"Does this name sound right?\" `" + titles[iteration] + "`");
  29.         Emoji yes = new Emoji("👍");
  30.         Emoji no = new Emoji("👎");
  31.         await messageSent.AddReactionAsync(yes);
  32.         await messageSent.AddReactionAsync(no);
  33.         string finalImage;
  34.         // wait for the user inputer
  35.         /* TODO: Figure out what's wrong with this */
  36.         while (true)
  37.         {
  38.             var usersReactedYes = await messageSent.GetReactionUsersAsync("👍");
  39.             var usersReactedNo = await messageSent.GetReactionUsersAsync("👎");
  40.             if (usersReactedYes.Contains(Context.User))
  41.             {
  42.                 await messageSent.RemoveAllReactionsAsync();
  43.                 await Context.Channel.SendMessageAsync("Tiphereth B: \"Here you go!\"");
  44.                 var detailsResult = await wikiArticleDetails.Details(Int32.Parse(resultSearch.Items[iteration].Id));
  45.                 finalImage = detailsResult.Items[resultSearch.Items[iteration].Id].Thumbnail.Remove(detailsResult.Items[resultSearch.Items[iteration].Id].Thumbnail.IndexOf("/revision") + 1);
  46.                 await Context.Channel.SendMessageAsync(finalImage);
  47.                 break;
  48.             }
  49.             else if (usersReactedNo.Contains(Context.User))
  50.             {
  51.                 await messageSent.DeleteAsync();
  52.                 messageSent = await Context.Channel.SendMessageAsync("Tiphereth B: \"What about this one?\" `" + titles[iteration] + "`");
  53.                 await messageSent.AddReactionAsync(new Emoji ("👍"));
  54.                 await messageSent.AddReactionAsync(new Emoji("👎"));
  55.                 iteration++;
  56.             }        
  57.         }
  58.         Console.ForegroundColor = ConsoleColor.DarkYellow;
  59.         Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " " + Context.User + " Image: " + searchInput);
  60.         Console.ResetColor();
  61.     }
  62. //NOTE: This is broken right now lmao
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement