Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions nekosbest/nekosbest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,22 @@ async def _api_call(self, ctx: commands.Context, endpoint: str) -> dict[str, Any
"Something went wrong while trying to contact API. Status code: %s",
response.status,
)
return await ctx.send(
await ctx.send(
"Something went wrong while trying to contact API. Please try again later.",
)
return None
data = await response.read()
return orjson.loads(data)

async def imgembedgen(
self, ctx: commands.Context, response: dict[str, Any], category: str
) -> None:
await ctx.typing()
data = response["results"][0]
results = response.get("results")
if not results:
await ctx.send("The API returned no data. Try again in a moment.")
return
data = results[0]
artist = data["artist_name"]
source = data["source_url"]
artist_link = data["artist_href"]
Expand Down Expand Up @@ -121,6 +126,10 @@ async def embedgen(self, ctx: commands.Context, member: discord.Member, action:
url = await self._api_call(ctx, action)
if url is None:
return
results = url.get("results")
if not results:
await ctx.send("The API returned no data. Try again in a moment.")
return
await ctx.typing()
user_config = self.config.user(ctx.author)
command_counts = await user_config.command_counts()
Expand All @@ -139,8 +148,8 @@ async def embedgen(self, ctx: commands.Context, member: discord.Member, action:
grammar = "times" if count > 1 else "time"
received_grammar = "times" if received_count > 1 else "time"
action_fmt = ACTIONS.get(action, action)
anime_name = url["results"][0]["anime_name"]
image_url = url["results"][0]["url"]
anime_name = results[0]["anime_name"]
image_url = results[0]["url"]

target_str = f"{member.mention}" if member and member != ctx.author else "themselves!"
description = f"**{ctx.author.mention} {action_fmt} {target_str}**\n"
Expand Down
5 changes: 4 additions & 1 deletion themoviedb/tmdb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@
"name": "KinoCheck - Your Ultimate Movie Destination!.",
},
"vertical": {"id": "UCpR3kmSyTYszJHWEcmpcnFQ", "name": "Vertical Official"},
"igntrailer": {"id": "UCWJ5MfdQZ6jXbF5gYuSAf5Q", "name": "IGN Movie Trailers"} # almost same as kinocheck but with more unseen trailers.
"igntrailer": {
"id": "UCWJ5MfdQZ6jXbF5gYuSAf5Q",
"name": "IGN Movie Trailers",
}, # almost same as kinocheck but with more unseen trailers.
}


Expand Down
Loading