From a99ad11f56ce26f219d6982b3c19857f34fc6e30 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Thu, 2 Jan 2025 18:59:28 +0000 Subject: Handle the case where get_top_posts returns an embed on error --- bot/exts/utilities/reddit.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot/exts/utilities/reddit.py b/bot/exts/utilities/reddit.py index 085be42a..19c39476 100644 --- a/bot/exts/utilities/reddit.py +++ b/bot/exts/utilities/reddit.py @@ -301,6 +301,11 @@ class Reddit(Cog): async with ctx.typing(): pages = await self.get_top_posts(subreddit=subreddit, time="all", paginate=True) + if isinstance(pages, Embed): + # If get_top_posts hits an error, then an error embed is returned, not actual posts. + await ctx.send(embed=pages) + return + await ctx.send(f"Here are the top {subreddit} posts of all time!") embed = Embed( color=Colour.og_blurple() -- cgit v1.2.3