Exemplo n.º 1
0
        public async Task Imgur(CommandContext ctx,
                                [Description("Search query to pass to Imgur.")][RemainingText]
                                string query)
        {
            await ctx.TriggerTypingAsync();

            var results = ImgurService.GetImgurGalleryAsync(Program.Settings.Tokens.ImgurToken, query).Result;
            var output  = new DiscordEmbedBuilder().WithColor(new DiscordColor("#89C623"));

            switch (results)
            {
            case GalleryImage image:
                output.WithDescription(image.Title ?? "Search results for " + Formatter.Bold(query) + " on Imgur");
                output.WithImageUrl(image.Link);
                await ctx.RespondAsync(output.Build()).ConfigureAwait(false);

                break;

            case GalleryAlbum album:
                output.WithDescription(album.Title ?? "Search results for " + Formatter.Bold(query) + " on Imgur");
                output.WithImageUrl(album.Link);
                await ctx.RespondAsync(output.Build()).ConfigureAwait(false);

                break;

            default:
                await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing)
                .ConfigureAwait(false);

                break;
            }
        }
Exemplo n.º 2
0
        public async Task GetImgurGalleryData()
        {
            var results = await ImgurService.GetImgurGalleryAsync("cats", GallerySortOrder.Top, TimeWindow.All).ConfigureAwait(false);

            Assert.IsNotNull(results);

            results = await ImgurService.GetImgurGalleryAsync("dogs", GallerySortOrder.Top, TimeWindow.All).ConfigureAwait(false);

            Assert.IsNotNull(results);
        }
Exemplo n.º 3
0
        public async Task GetImgurGalleryData()
        {
            var results = await ImgurService.GetImgurGalleryAsync(TestSetup.Tokens.ImgurToken, "cats")
                          .ConfigureAwait(false);

            Assert.IsNotNull(results);

            results = await ImgurService.GetImgurGalleryAsync(TestSetup.Tokens.ImgurToken, "dogs")
                      .ConfigureAwait(false);

            Assert.IsNotNull(results);
        }
Exemplo n.º 4
0
        public async Task Imgur(CommandContext ctx,
                                [Description("Search query to pass to Imgur")][RemainingText] string query)
        {
            var results = ImgurService.GetImgurGalleryAsync(query).Result;

            switch (results)
            {
            case GalleryAlbum _:
                await ctx.RespondAsync(((GalleryAlbum)results).Link).ConfigureAwait(false);

                break;

            case GalleryImage _:
                await ctx.RespondAsync(((GalleryImage)results).Link).ConfigureAwait(false);

                break;

            default:
                await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing).ConfigureAwait(false);

                break;
            }
        }