From 13d20733878a91d05b28383f6b1ba2226725cb2c Mon Sep 17 00:00:00 2001 From: artie Date: Sun, 7 Apr 2024 19:06:10 +0200 Subject: [PATCH] handle anilist error --- cogs/anime.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cogs/anime.py b/cogs/anime.py index 444eacf..d445083 100644 --- a/cogs/anime.py +++ b/cogs/anime.py @@ -78,10 +78,13 @@ class Anime(commands.Cog): async with self.bot.session.post("https://graphql.anilist.co", json=payload) as r: data = await r.json() + if not data.get("data"): + return await ctx.reply(f"Anilist Error: {r.status} {r.reason}") + data = data["data"]["MediaListCollection"]["lists"][0]["entries"] if not data: - return await ctx.reply("Artie is currently not watching any anime :()") + return await ctx.reply("Artie is currently not watching any anime :(") image_url = data[0]["media"]["coverImage"]["extraLarge"] color = data[0]["media"]["coverImage"]["color"]