Skip to content

Commit

Permalink
[Discord] Improve anime command coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmon758 committed Dec 15, 2023
1 parent 368bac3 commit 2c92ac4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Discord/cogs/entertainment.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ async def anime(self, ctx, *, search: str):
json = {"query": query, "variables": {"search": search}}
) as resp:
data = await resp.json()

if not (media := data["data"]["Media"]) and "errors" in data:
await ctx.embed_reply(
f"{ctx.bot.error_emoji} Error: {data['errors'][0]['message']}"
)
return

# Title
english_title = media["title"]["english"]
native_title = media["title"]["native"]
Expand Down Expand Up @@ -202,9 +204,12 @@ async def anime(self, ctx, *, search: str):
fields.append(("Tags", ", ".join(tags)))
elif tags:
non_inline_fields.append(("Tags", ", ".join(tags), False))

await ctx.embed_reply(
description, title = title, title_url = media["siteUrl"],
title = title,
title_url = media["siteUrl"],
thumbnail_url = media["coverImage"]["extraLarge"],
description = description,
fields = fields + non_inline_fields,
image_url = media["bannerImage"]
)
Expand Down

0 comments on commit 2c92ac4

Please sign in to comment.