Exemple #1
0
 public void Delete(ERating item)
 {
     if (item == _item.GetAll().FirstOrDefault(x => item.Rating == item.Rating))
     {
         _item.Delete(item);
         Save();
     }
 }
Exemple #2
0
 public ERating Add(ERating item)
 {
     if (item != _item.GetAll().FirstOrDefault(x => item.Rating == item.Rating))
     {
         ERating temp = _item.Add(item);
         Save();
         return(temp);
     }
     else
     {
         throw new Exception("This Subject Alredy Added");
     }
 }
        public async Task FetchWallpaper(CommandContext ctx, params string[] args)
        {
            await ctx.TriggerTypingAsync();

            string tags = GetTagsString(args.ToList());

            int postCount = (await GetPosts(tags))?.Count ?? 0;

            if (postCount <= 0)
            {
                await ctx.RespondAsync("No posts found with the given tag");

                return;
            }

            int page = new RealRandom().Next(postCount);

            KonachanRoot posts = await GetPosts(tags, page);

            ERating rating = posts.KonachanPost.Rating switch
            {
                "e" => ERating.Explicit,
                "q" => ERating.Questionable,
                "s" => ERating.Safe,
                _ => ERating.Safe
            };

            DiscordEmbed embed = new DiscordEmbedBuilder()
                                 .WithImageUrl(posts.KonachanPost.FileUrl)
                                 .WithAuthor(posts.KonachanPost.Author)
                                 .WithDescription(
                $"**Rating:** {rating}\n" +
                $"**Score:** {posts.KonachanPost.Score}\n" +
                $"**Tags:** {posts.KonachanPost.Tags}"
                )
                                 .Build();


            await ctx.RespondAsync(embed : embed);
        }
Exemple #4
0
 public void Delete(ERating item)
 {
     _context.Rating.Remove(item);
 }
Exemple #5
0
 public ERating Add(ERating item)
 {
     return(_context.Rating.Add(item));
 }