diff options
| author | 2020-02-09 11:31:58 +0530 | |
|---|---|---|
| committer | 2020-02-09 11:31:58 +0530 | |
| commit | d823a3c582040e0d8b2f8f43ff8da752388bbd3d (patch) | |
| tree | 87c0621309120585c023b34be807d61de15d07eb | |
| parent | rolled back to original pipfile.lock (diff) | |
Removed un-wanted code and using random.simple() to select 5 random unique reddit posts insted of using a while loop
| -rw-r--r-- | bot/seasons/evergreen/reddit.py | 19 | 
1 files changed, 6 insertions, 13 deletions
| diff --git a/bot/seasons/evergreen/reddit.py b/bot/seasons/evergreen/reddit.py index 8a7ebf26..811f5781 100644 --- a/bot/seasons/evergreen/reddit.py +++ b/bot/seasons/evergreen/reddit.py @@ -56,22 +56,15 @@ class Reddit(commands.Cog):              return await ctx.send('No posts available!')          if posts[1]["data"]["over_18"] is True: -            return await ctx.send("You cannot access this Subreddit.") - -        upvote_emoji = self.bot.get_emoji(565557799040319508) -        comment_emoji = self.bot.get_emoji(565576076483624960) -        user_emoji = "🎅" +            return await ctx.send( +                "You cannot access this Subreddit as it is ment for those who " +                "are 18 years or older." +            ) -        # embed_titles = discord.Embed(colour=0xf9f586)          embed_titles = "" -        random_posts = [] -        while True: -            if len(random_posts) == 5: -                break -            rand_post = random.choice(posts) -            if rand_post not in random_posts: -                random_posts.append(rand_post) +        # Chooses k unique random elements from a population sequence or set. +        random_posts = random.sample(posts, k=5)          # -----------------------------------------------------------          # This code below is bound of change when the emojis are added. | 
