Beispiel #1
0
        public async Task MangaSearch([Remainder] string Query)
        {
            await Context.Channel.TriggerTypingAsync();

            var mangaSearch = await WebUtil.MangaSearch(Query);

            //Quick If to see if manga had results
            if (mangaSearch == null || mangaSearch.Results == null || mangaSearch.Results.Count <= 0)
            {
                await Context.Channel.SendMessageAsync($"Gomen, Senpai... No results.");

                return;
            }

            //Sends embed of manga titles from results
            var listMsg = await ReplyAsync("", false, WebUtil.MangaListEmbed(mangaSearch).Build());

            var response = await NextMessageAsync(
                new Criteria <IMessage>()
                .AddCriterion(new EnsureSourceUserCriterion())
                .AddCriterion(new EnsureSourceChannelCriterion())
                .AddCriterion(new EnsureRangeCriterion(7, Program.GetPrefix(Context))),
                new TimeSpan(0, 0, 23));

            long id;

            try
            {
                int i = int.Parse(response.Content);
                id = mangaSearch.Results.Skip(i - 1).FirstOrDefault().MalId;
            }
            catch
            {
                _ = Context.Message.DeleteAsync();
                return;
            }
            _ = response.DeleteAsync();

            if (mangaSearch != null)
            {
                await Context.Channel.TriggerTypingAsync();

                var endManga = await WebUtil.GetManga(id); //EndManga becomes the manga, it uses ID to get propa page umu

                await listMsg.ModifyAsync(x => x.Embed = WebUtil.MangaEmbed(endManga).Build());
            }
        }