Example #1
0
            public async Task GifAsync([Remainder] string query)
            {
                GiphyDotNet.Model.Results.GiphySearchResult gif = await _giphy.GifSearch(new SearchParameter { Query = query });

                EmbedBuilder embed = new EmbedBuilder();

                if (!gif.Data.Any())
                {
                    embed.WithTitle("No gif found")
                    .WithDescription($"Couldn't find any gif for {query.InlineCode()}");
                }
                else
                {
                    embed.WithImageUrl(gif.Data[_random.Next(gif.Data.Length)].Images.Original.Url);
                }

                await ReplyEmbedAsync(embed);
            }
Example #2
0
        public async Task <ImageData[]> GetTrendingGifsAsync(int amount = 1)
        {
            if (this.IsDisabled())
            {
                return(null);
            }

            if (amount < 1 || amount > 20)
            {
                throw new ArgumentException("Result amount out of range (max 20)", nameof(amount));
            }

            SearchResult res = await this.giphy.TrendingGifs(new TrendingParameter {
                Limit = amount
            }).ConfigureAwait(false);

            return(res.Data);
        }
Example #3
0
        public async Task <ImageData[]?> GetTrendingGifsAsync(int amount = 1)
        {
            if (this.IsDisabled)
            {
                return(null);
            }

            if (amount is < 1 or > 20)
            {
                amount = 1;
            }

            SearchResult res = await this.giphy !.TrendingGifs(new TrendingParameter {
                Limit = amount
            }).ConfigureAwait(false);

            return(res.Data);
        }
Example #4
0
        public async Task <ImageData[]?> SearchStickerAsync(string query, int amount = 1)
        {
            if (this.IsDisabled)
            {
                return(null);
            }

            if (amount is < 1 or > 20)
            {
                amount = 1;
            }

            SearchResult res = await this.giphy !.StickerSearch(new SearchParameter {
                Query = query,
                Limit = amount
            }).ConfigureAwait(false);

            return(res.Data);
        }
Example #5
0
        public async Task <ImageData[]> SearchAsync(string query, int amount = 1)
        {
            if (this.IsDisabled())
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(query))
            {
                throw new ArgumentException("Query missing!", nameof(query));
            }

            if (amount < 1 || amount > 20)
            {
                throw new ArgumentException("Result amount out of range (max 20)", nameof(amount));
            }

            SearchResult res = await this.giphy.GifSearch(new SearchParameter {
                Query = query,
                Limit = amount
            }).ConfigureAwait(false);

            return(res.Data);
        }