Skip to content

Commit a99ad11

Browse files
committed
Handle the case where get_top_posts returns an embed on error
1 parent 9512355 commit a99ad11

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bot/exts/utilities/reddit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ async def top_command(self, ctx: Context, subreddit: Subreddit = "r/Python") ->
301301
async with ctx.typing():
302302
pages = await self.get_top_posts(subreddit=subreddit, time="all", paginate=True)
303303

304+
if isinstance(pages, Embed):
305+
# If get_top_posts hits an error, then an error embed is returned, not actual posts.
306+
await ctx.send(embed=pages)
307+
return
308+
304309
await ctx.send(f"Here are the top {subreddit} posts of all time!")
305310
embed = Embed(
306311
color=Colour.og_blurple()

0 commit comments

Comments
 (0)