Example #1
0
        private Embed CreateEmbed(bool isAnime, Response.AnimeManga res)
        {
            string       fullName = res.name + ((res.alternativeTitles == null || res.alternativeTitles.Length == 0) ? ("") : (" (" + string.Join(", ", res.alternativeTitles) + ")"));
            EmbedBuilder embed    = new EmbedBuilder()
            {
                Title       = fullName.Length > 256 ? res.name : fullName,
                Url         = res.animeUrl,
                Color       = Color.Green,
                ImageUrl    = res.imageUrl,
                Description = res.synopsis
            };

            if (isAnime && res.episodeCount != null)
            {
                embed.AddField(Sentences.AnimeEpisodes(Context.Guild), res.episodeCount.Value + ((res.episodeLength != null) ? (" " + Sentences.AnimeLength(Context.Guild, res.episodeLength.Value)) : ("")), true);
            }
            if (res.rating != null)
            {
                embed.AddField(Sentences.AnimeRating(Context.Guild), res.rating.Value, true);
            }
            embed.AddField(Sentences.ReleaseDate(Context.Guild), ((res.startDate != null) ? res.startDate.Value.ToString(Base.Sentences.DateHourFormatShort(Context.Guild)) + " - " + ((res.endDate != null) ? (res.endDate.Value.ToString(Base.Sentences.DateHourFormatShort(Context.Guild))) : (Sentences.Unknown(Context.Guild))) : (Sentences.ToBeAnnounced(Context.Guild))), true);
            if (!string.IsNullOrEmpty(res.ageRating))
            {
                embed.AddField(Sentences.AnimeAudiance(Context.Guild), res.ageRating, true);
            }
            return(embed.Build());
        }
Example #2
0
        public async Task Vndb(params string[] args)
        {
            Utilities.CheckAvailability(Context.Guild.Id, Program.Module.Vn);
            await p.DoAction(Context.User, Context.Guild.Id, Program.Module.Vn);

            var result = await Vn.SearchVn(args, !((ITextChannel)Context.Channel).IsNsfw);

            switch (result.error)
            {
            case Error.Vn.Help:
                await ReplyAsync(Sentences.VndbHelp(Context.Guild.Id));

                break;

            case Error.Vn.NotFound:
                await ReplyAsync(Sentences.VndbNotFound(Context.Guild.Id));

                break;

            case Error.Vn.None:
                EmbedBuilder embed = new EmbedBuilder()
                {
                    Title       = result.answer.originalTitle == null ? result.answer.title : result.answer.originalTitle + " (" + result.answer.title + ")",
                    Url         = result.answer.vnUrl,
                    ImageUrl    = result.answer.imageUrl,
                    Description = result.answer.description,
                    Color       = Color.Blue
                };
                embed.AddField(Sentences.AvailableEnglish(Context.Guild.Id), result.answer.isAvailableEnglish ? Base.Sentences.YesStr(Context.Guild.Id) : Base.Sentences.NoStr(Context.Guild.Id), true);
                embed.AddField(Sentences.AvailableWindows(Context.Guild.Id), result.answer.isAvailableWindows ? Base.Sentences.YesStr(Context.Guild.Id) : Base.Sentences.NoStr(Context.Guild.Id), true);
                string length = Sentences.Unknown(Context.Guild.Id);
                switch (result.answer.length)
                {
                case VisualNovelLength.VeryShort: length = Sentences.Hours(Context.Guild.Id, "< 2 "); break;

                case VisualNovelLength.Short: length = Sentences.Hours(Context.Guild.Id, "2 - 10 "); break;

                case VisualNovelLength.Medium: length = Sentences.Hours(Context.Guild.Id, "10 - 30 "); break;

                case VisualNovelLength.Long: length = Sentences.Hours(Context.Guild.Id, "30 - 50 "); break;

                case VisualNovelLength.VeryLong: length = Sentences.Hours(Context.Guild.Id, "> 50 "); break;
                }
                embed.AddField(Sentences.Length(Context.Guild.Id), length, true);
                embed.AddField(Sentences.VndbRating(Context.Guild.Id), result.answer.rating + " / 10", true);
                string releaseDate;
                if (result.answer.releaseYear == null)
                {
                    releaseDate = Sentences.Tba(Context.Guild.Id);
                }
                else
                {
                    releaseDate = result.answer.releaseYear.ToString();
                    if (result.answer.releaseMonth != null)
                    {
                        releaseDate = Utilities.AddZero(result.answer.releaseMonth.ToString()) + "/" + releaseDate;
                    }
                    if (result.answer.releaseDay != null)
                    {
                        releaseDate = Utilities.AddZero(result.answer.releaseDay.ToString()) + "/" + releaseDate;
                    }
                }
                embed.AddField(Sentences.ReleaseDate(Context.Guild.Id), releaseDate, true);
                await ReplyAsync("", false, embed.Build());

                break;

            default:
                throw new NotImplementedException();
            }
        }