diff options
| author | 2020-09-28 23:41:48 +0530 | |
|---|---|---|
| committer | 2020-09-28 23:41:48 +0530 | |
| commit | f32a665cd0a03d8dbf4802643d32902c99bbd9ee (patch) | |
| tree | 3d852f78bb1c12f51d04ed2c444eca8f24943c60 | |
| parent | Merge remote-tracking branch 'upstream/master' into filter_reddit (diff) | |
Filter out reddit posts which are meant for users 18 years of older and send the rest.
| -rw-r--r-- | bot/exts/info/reddit.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bot/exts/info/reddit.py b/bot/exts/info/reddit.py index 606c26aa7..f2aecc498 100644 --- a/bot/exts/info/reddit.py +++ b/bot/exts/info/reddit.py @@ -140,7 +140,12 @@ class Reddit(Cog): # Got appropriate response - process and return. content = await response.json() posts = content["data"]["children"] - if posts[0]["data"]["over_18"]: + + for post in posts: + if post["data"]["over_18"]: + posts.remove(post) + + if not posts: resp_not_allowed = [ { "error": "Oops ! Looks like this subreddit, doesn't fit in the scope of the server." |