From e67cc2e57c8576b80d2016192bf593488cb8407a Mon Sep 17 00:00:00 2001 From: Evanroby <107794516+Evanroby@users.noreply.github.com> Date: Sun, 12 Jul 2026 08:35:04 +0200 Subject: [PATCH 1/2] [NekosBest] return None on failed API call, guard empty results. --- nekosbest/nekosbest.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nekosbest/nekosbest.py b/nekosbest/nekosbest.py index 0526ff9d..37fcc3e5 100644 --- a/nekosbest/nekosbest.py +++ b/nekosbest/nekosbest.py @@ -75,9 +75,10 @@ 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) @@ -85,7 +86,11 @@ 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"] @@ -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() @@ -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" From 66a08fc257eae26844deb4283334829f11b03af8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jul 2026 06:36:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- themoviedb/tmdb_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themoviedb/tmdb_utils.py b/themoviedb/tmdb_utils.py index 8db581ad..89e756a8 100644 --- a/themoviedb/tmdb_utils.py +++ b/themoviedb/tmdb_utils.py @@ -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. }