private async Task HandleResults(string url, IMessageChannel channel) { IIqdbClient api = new IqdbClient(); IqdbApi.Models.SearchResult res; try { res = await api.SearchUrl(url); } //Too lazy to implement separate exceptions this'll do catch (Exception) { await channel.SendErrorAsync("IQDB serarch error'd. Try a different image?"); return; } //Lets get the results maybe? if (res.Matches.Where(x => x.MatchType == IqdbApi.Enums.MatchType.Best).Count() == 0) { await channel.SendErrorAsync("No source found for that image, sadly."); return; } //SWEET MOTHER OF GOD WE GOT SOMETHING EmbedBuilder e = new EmbedBuilder().WithOkColour().WithTitle("Potential Match Found").WithDescription("This is the \"best\" match according to IQDB."); EmbedFieldBuilder efb = new EmbedFieldBuilder().WithName("URL"); //We only need the best Match bestmatch = res.Matches.Where(x => x.MatchType == IqdbApi.Enums.MatchType.Best).First(); //There's gotta be a better way to do this but I'm okay with this as is string urlFix = bestmatch.Url; if (!urlFix.StartsWith("http:") && urlFix.StartsWith("//")) { urlFix = "http:" + urlFix; } //combine shit efb.WithValue(urlFix); e.AddField(efb); //Finally await channel.BlankEmbedAsync(e.Build()); }
public static async Task <SearchResult> IqdbFileSearchAsync(FileStream file) { IIqdbClient api = new IqdbClient(); return(await api.SearchFile(file)); }
// IQDB public static async Task <SearchResult> IqdbUrlSearchAsync(string url) { IIqdbClient api = new IqdbClient(); return(await api.SearchUrl(url)); }