mirror of
https://github.com/artiemis/artemis.git
synced 2026-02-14 08:31:55 +00:00
handle anilist error
This commit is contained in:
parent
40f9e8e4d5
commit
13d2073387
@ -78,10 +78,13 @@ class Anime(commands.Cog):
|
|||||||
async with self.bot.session.post("https://graphql.anilist.co", json=payload) as r:
|
async with self.bot.session.post("https://graphql.anilist.co", json=payload) as r:
|
||||||
data = await r.json()
|
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"]
|
data = data["data"]["MediaListCollection"]["lists"][0]["entries"]
|
||||||
|
|
||||||
if not data:
|
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"]
|
image_url = data[0]["media"]["coverImage"]["extraLarge"]
|
||||||
color = data[0]["media"]["coverImage"]["color"]
|
color = data[0]["media"]["coverImage"]["color"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user