public async Task <GetStatusImageResponse> GetStatusImageAsync(int statusCode, GetStatusImageOptions options = null, CancellationToken cancellationToken = default) { var httpStatusCode = HttpStatusCode.CreateFromCode(statusCode); var giphyClient = new GiphyApiClient(_httpClient, new GiphyApiClientSettings()); var response = await giphyClient.SearchAsync(CreateSearchRequest(httpStatusCode, options), cancellationToken); GifResponse gif; if (options != null && options.UseRandomFromSet) { var rnd = new Random(); int number = rnd.Next(0, LimitForRandom); gif = response.Gifs.Skip(number).Take(1).Single(); } else { gif = response.Gifs.SingleOrDefault(); } var imageUrl = GetSmallestImage(gif); return(new GetStatusImageResponse { Code = httpStatusCode.Code, Name = httpStatusCode.Name, ImageUrl = imageUrl }); }
private static async Task Main(string[] args) { var client = new GiphyApiClient(new HttpClient()); var request = new SearchRequest(GiphyApiKey) { Query = "cheeseburgers", Limit = 1 }; var response = await client.SearchAsync(request); Console.Write(response.Gifs.First().Images.Original.Url); Console.ReadKey(); }
public async Task Gif([Remainder] string text) { const string giphyApiKey = "MISSING KEY*******"; //PUT YOUR KEY HERE var client = new GiphyApiClient(new HttpClient()); var request = new SearchRequest(giphyApiKey) { Query = text, Limit = 3 }; var response = await client.SearchAsync(request); Console.Write(response.Gifs.First().Images.Original.Url); await ReplyAsync("URL:" + response.Gifs.First().Images.Original.Url); // how to send message }