public GiphyReponse GetRandomImage(string tags) { GiphyReponse r = new GiphyReponse(); string url = string.Empty; string appendUrl = string.Empty; if (string.IsNullOrEmpty(tags)) { url = $"/gifs/random"; } else { tags = tags.Replace(" ", "+"); url = $"/gifs/random"; appendUrl = $"&tag={tags}"; } r = JsonConvert.DeserializeObject <GiphyReponse>(ApiRequest(url, appendUrl)); return(r); }
public async Task Giphy([Remainder] string args = "") { bool isEnabled = CheckGiphyEnabled(Context); var embed = new EmbedBuilder(); embed.WithColor(new Color(0, 255, 255)); if (isEnabled) { StringBuilder sb = new StringBuilder(); GiphyReponse r = new GiphyReponse(); try { if (string.IsNullOrEmpty(args)) { r = _api.GetRandomImage(string.Empty); embed.Title = $"__Giphy for [**{Context.User.Username}**]__"; } else { r = _api.GetRandomImage(args); embed.Title = $"__Giphy for [**{Context.User.Username}**] ({args})__"; } embed.ImageUrl = r.data.fixed_height_small_url; await _cc.Reply(Context, embed); } catch (Exception ex) { await _cc.Reply(Context, "Sorry, something went wrong :("); Console.WriteLine($"Giphy Command Error -> [{ex.Message}]"); } } else { embed.Title = $"Sorry, Giphy is disabled here :(\n"; embed.Description = $"Use {_prefix}giphy-toggle to enable it"; await _cc.Reply(Context, embed); } }