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 = []
content = ""
og_post = None
if not post.is_self:
if "crosspost_parent_list" in vars(post):
og_post = post # noqa: F841
post = await self.api.submission(post.crosspost_parent_list[0]["id"])
await post.load()
@ -76,9 +76,14 @@ class RedditCog(Cog):
break
if "selftext" in vars(post) and post.selftext:
text = post.selftext
if post.spoiler:
text = "||" + text + "||"
content += "\n\n" + post.selftext
if len(content) > 900:
content = content[:900] + "..."
if post.spoiler:
content += "||"
content += f"\n\n[View this post]({url})"
if not images and not content:
@ -96,9 +101,7 @@ class RedditCog(Cog):
url=url,
color=color,
)
base_embed.set_author(
name="u/" + post.author.name, url=author_url, icon_url=author_icon
)
base_embed.set_author(name="u/" + post.author.name, url=author_url, icon_url=author_icon)
base_embed.set_footer(
text="Reddit", icon_url="https://www.redditinc.com/assets/images/site/reddit-logo.png"
)
@ -405,7 +408,7 @@ class RedditCog(Cog):
await post.load()
except (NotFound, Forbidden, Redirect) as e:
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
embeds = await self.post_embeds(post.subreddit, post)