diff options
| author | 2020-10-17 11:34:28 +0200 | |
|---|---|---|
| committer | 2020-10-17 11:34:28 +0200 | |
| commit | ef68d4e36d4b14786978ff01618b66c6e0d9fbdc (patch) | |
| tree | cf87c0b20003f899b36a9dec9036ba205b002ee0 | |
| parent | Merge pull request #1242 from python-discord/sebastiaan/features/whitelister-... (diff) | |
| parent | Merge branch 'master' into filter_reddit (diff) | |
PR #1157 Reddit: filter NSFW posts
| -rw-r--r-- | bot/exts/info/reddit.py | 8 | 
1 files changed, 5 insertions, 3 deletions
| diff --git a/bot/exts/info/reddit.py b/bot/exts/info/reddit.py index debe40c82..bad4c504d 100644 --- a/bot/exts/info/reddit.py +++ b/bot/exts/info/reddit.py @@ -140,7 +140,10 @@ class Reddit(Cog):                  # Got appropriate response - process and return.                  content = await response.json()                  posts = content["data"]["children"] -                return posts[:amount] + +                filtered_posts = [post for post in posts if not post["data"]["over_18"]] + +                return filtered_posts[:amount]              await asyncio.sleep(3) @@ -163,12 +166,11 @@ class Reddit(Cog):              amount=amount,              params={"t": time}          ) -          if not posts:              embed.title = random.choice(ERROR_REPLIES)              embed.colour = Colour.red()              embed.description = ( -                "Sorry! We couldn't find any posts from that subreddit. " +                "Sorry! We couldn't find any SFW posts from that subreddit. "                  "If this problem persists, please let us know."              ) | 
