Example #1
0
 public override bool MoveNext()
 {
     if (m_Random == null)
     {
         m_Random = RealRandom.Create(MinValue, MaxValue);
     }
     Current = m_Random.Next();
     return(true);
 }
        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);
        }
 public void Initialize()
 {
     //init spinner
     randomizer = new RealRandom();
 }
Example #4
0
 public void Initialize()
 {
     //init spinner
     randomizer = new RealRandom();
 }