From 12f5b9651d6eb6cf00c1cb4feed1c1fed617f657 Mon Sep 17 00:00:00 2001 From: Marco Thomas Date: Fri, 9 Oct 2020 12:10:48 +0200 Subject: [PATCH] Add nfsw check to reddit.py --- cogs/reddit.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cogs/reddit.py b/cogs/reddit.py index 5fa8d64..712f1f3 100644 --- a/cogs/reddit.py +++ b/cogs/reddit.py @@ -37,14 +37,18 @@ class Reddit(commands.Cog): except ValueError as e: await ctx.send(f"Invalid Argument: {e}") - # WORKS rand_post = random.randint(1, 100) # Make sure you're not sending a pinned post for i in range(0, rand_post): submission = next(x for x in posts if not x.stickied) - await ctx.send(f"'{submission.title}' by {submission.author.name} - 🔼 {submission.score}") - await ctx.send(submission.url) + if submission.over_18 and not ctx.channel.is_nsfw(): + await ctx.send("The post is marked as NSFW, but your text channel isn't!") + else: + if submission.over_18: + await ctx.send("❗ NSFW ❗") + await ctx.send(f"'{submission.title}' by {submission.author.name} - 🔼 {submission.score}") + await ctx.send(submission.url) def setup(bot):