From 602cea9058a8796bebc6700db7534698a8619728 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 2 May 2022 13:58:19 -0600 Subject: [PATCH] Change nsfw filtering --- jarvis/cogs/reddit.py | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/jarvis/cogs/reddit.py b/jarvis/cogs/reddit.py index 934d804..01de656 100644 --- a/jarvis/cogs/reddit.py +++ b/jarvis/cogs/reddit.py @@ -255,8 +255,14 @@ class RedditCog(Scale): return embeds = await self.post_embeds(subreddit, post) - ephemeral = post.over_18 and not ctx.channel.nsfw - await ctx.send(embeds=embeds, ephemeral=ephemeral) + if post.over_18 and not ctx.channel.nsfw: + try: + await ctx.author.send(embeds=embeds) + await ctx.send("Hey! Due to content, I had to DM the result to you") + except Exception: + await ctx.send("Hey! Due to content, I cannot share the result") + else: + await ctx.send(embeds=embeds) @reddit.subcommand(sub_cmd_name="top", sub_cmd_description="Get the top post of a subreddit") @slash_option( @@ -297,7 +303,14 @@ class RedditCog(Scale): return embeds = await self.post_embeds(subreddit, post) - await ctx.send(embeds=embeds) + if post.over_18 and not ctx.channel.nsfw: + try: + await ctx.author.send(embeds=embeds) + await ctx.send("Hey! Due to content, I had to DM the result to you") + except Exception: + await ctx.send("Hey! Due to content, I cannot share the result") + else: + await ctx.send(embeds=embeds) @reddit.subcommand( sub_cmd_name="random", sub_cmd_description="Get a random post of a subreddit" @@ -326,8 +339,14 @@ class RedditCog(Scale): return embeds = await self.post_embeds(subreddit, post) - ephemeral = post.over_18 and not ctx.channel.nsfw - await ctx.send(embeds=embeds, ephemeral=ephemeral) + if post.over_18 and not ctx.channel.nsfw: + try: + await ctx.author.send(embeds=embeds) + await ctx.send("Hey! Due to content, I had to DM the result to you") + except Exception: + await ctx.send("Hey! Due to content, I cannot share the result") + else: + await ctx.send(embeds=embeds) @reddit.subcommand( sub_cmd_name="rising", sub_cmd_description="Get a rising post of a subreddit" @@ -356,8 +375,14 @@ class RedditCog(Scale): return embeds = await self.post_embeds(subreddit, post) - ephemeral = post.over_18 and not ctx.channel.nsfw - await ctx.send(embeds=embeds, ephemeral=ephemeral) + if post.over_18 and not ctx.channel.nsfw: + try: + await ctx.author.send(embeds=embeds) + await ctx.send("Hey! Due to content, I had to DM the result to you") + except Exception: + await ctx.send("Hey! Due to content, I cannot share the result") + else: + await ctx.send(embeds=embeds) def setup(bot: Snake) -> None: