Add nfsw check to reddit.py

This commit is contained in:
Marco Thomas
2020-10-09 12:10:48 +02:00
parent 7cfa665060
commit 12f5b9651d

View File

@@ -37,14 +37,18 @@ class Reddit(commands.Cog):
except ValueError as e: except ValueError as e:
await ctx.send(f"Invalid Argument: {e}") await ctx.send(f"Invalid Argument: {e}")
# WORKS
rand_post = random.randint(1, 100) rand_post = random.randint(1, 100)
# Make sure you're not sending a pinned post # Make sure you're not sending a pinned post
for i in range(0, rand_post): for i in range(0, rand_post):
submission = next(x for x in posts if not x.stickied) submission = next(x for x in posts if not x.stickied)
await ctx.send(f"'{submission.title}' by {submission.author.name} - 🔼 {submission.score}") if submission.over_18 and not ctx.channel.is_nsfw():
await ctx.send(submission.url) 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): def setup(bot):