diff --git a/helper.py b/helper.py index d9948e8..b970df5 100644 --- a/helper.py +++ b/helper.py @@ -13,9 +13,12 @@ def getRecentDiscussion(): recent = {"title": "N/A", "link": "#"} obj = python_requests.get("https://talk.zhdo.space/api/recent/posts/week") if obj.status_code == 200: - recent["title"] = str(obj.json()[0]["topic"]["title"]) - recent["link"] = discussionPrefix + str(obj.json()[0]["topic"]["slug"]) - return recent + if not obj.json(): + return recent + else: + recent["title"] = str(obj.json()[0]["topic"]["title"]) + recent["link"] = discussionPrefix + str(obj.json()[0]["topic"]["slug"]) + return recent else: return "error"