Beispiel #1
0
        public GiphyResponses GetRandomImage(string tags)
        {
            GiphyResponses r         = new GiphyResponses();
            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 <GiphyResponses>(ApiRequest(url, appendUrl));
            return(r);
        }
Beispiel #2
0
        public async Task Giph([Remainder] string args = "")
        {
            bool isEnabled = CheckGiphyEnabled(Context);
            var  embed     = new EmbedBuilder();

            embed.WithColor(new Color(0, 255, 255));
            if (isEnabled)
            {
                StringBuilder  sb = new StringBuilder();
                GiphyResponses r  = new GiphyResponses();
                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 _channelServices.Reply(Context, embed);
                }
                catch (Exception ex)
                {
                    await _channelServices.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 _channelServices.Reply(Context, embed);
            }
        }