Change message for post not found

This commit is contained in:
Zeva Rose 2022-05-07 13:15:34 -06:00
parent 4599bd31bd
commit ad97bae9f7

View file

@ -56,7 +56,7 @@ class RedditCog(Cog):
fields = [] fields = []
content = "" content = ""
og_post = None og_post = None
if not post.is_self: if "crosspost_parent_list" in vars(post):
og_post = post # noqa: F841 og_post = post # noqa: F841
post = await self.api.submission(post.crosspost_parent_list[0]["id"]) post = await self.api.submission(post.crosspost_parent_list[0]["id"])
await post.load() await post.load()
@ -76,9 +76,14 @@ class RedditCog(Cog):
break break
if "selftext" in vars(post) and post.selftext: if "selftext" in vars(post) and post.selftext:
text = post.selftext
if post.spoiler:
text = "||" + text + "||"
content += "\n\n" + post.selftext content += "\n\n" + post.selftext
if len(content) > 900: if len(content) > 900:
content = content[:900] + "..." content = content[:900] + "..."
if post.spoiler:
content += "||"
content += f"\n\n[View this post]({url})" content += f"\n\n[View this post]({url})"
if not images and not content: if not images and not content:
@ -96,9 +101,7 @@ class RedditCog(Cog):
url=url, url=url,
color=color, color=color,
) )
base_embed.set_author( base_embed.set_author(name="u/" + post.author.name, url=author_url, icon_url=author_icon)
name="u/" + post.author.name, url=author_url, icon_url=author_icon
)
base_embed.set_footer( base_embed.set_footer(
text="Reddit", icon_url="https://www.redditinc.com/assets/images/site/reddit-logo.png" text="Reddit", icon_url="https://www.redditinc.com/assets/images/site/reddit-logo.png"
) )
@ -405,7 +408,7 @@ class RedditCog(Cog):
await post.load() await post.load()
except (NotFound, Forbidden, Redirect) as e: except (NotFound, Forbidden, Redirect) as e:
self.logger.debug(f"Submission {sid} raised {e.__class__.__name__} in post") self.logger.debug(f"Submission {sid} raised {e.__class__.__name__} in post")
await ctx.send("Subreddit may be private, quarantined, or nonexistent.", ephemeral=True) await ctx.send("Post could not be found.", ephemeral=True)
return return
embeds = await self.post_embeds(post.subreddit, post) embeds = await self.post_embeds(post.subreddit, post)