diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/exts/fun/snakes/_snakes_cog.py | 8 | ||||
| -rw-r--r-- | bot/exts/holidays/halloween/scarymovie.py | 19 | ||||
| -rw-r--r-- | bot/resources/utilities/ryanzec_colours.json | 1 |
3 files changed, 21 insertions, 7 deletions
diff --git a/bot/exts/fun/snakes/_snakes_cog.py b/bot/exts/fun/snakes/_snakes_cog.py index 96718200..d0542c23 100644 --- a/bot/exts/fun/snakes/_snakes_cog.py +++ b/bot/exts/fun/snakes/_snakes_cog.py @@ -598,7 +598,7 @@ class Snakes(Cog): Written by Momo and kel. Modified by juan and lemon. """ - with ctx.typing(): + async with ctx.typing(): # Generate random snake attributes width = random.randint(6, 10) @@ -637,7 +637,7 @@ class Snakes(Cog): Created by Ava and eivl. """ - with ctx.typing(): + async with ctx.typing(): if name is None: name = await Snake.random() @@ -693,7 +693,7 @@ class Snakes(Cog): Made by Ava and eivl. Modified by lemon. """ - with ctx.typing(): + async with ctx.typing(): image = None @@ -1047,7 +1047,7 @@ class Snakes(Cog): Written by Momo and kel. Modified by lemon. """ - with ctx.typing(): + async with ctx.typing(): embed = Embed() user = ctx.author diff --git a/bot/exts/holidays/halloween/scarymovie.py b/bot/exts/holidays/halloween/scarymovie.py index 74bcef90..9f1a95fd 100644 --- a/bot/exts/holidays/halloween/scarymovie.py +++ b/bot/exts/holidays/halloween/scarymovie.py @@ -5,7 +5,7 @@ from discord import Embed from discord.ext import commands from bot.bot import Bot -from bot.constants import Tokens +from bot.constants import Colours, NEGATIVE_REPLIES, Tokens log = logging.getLogger(__name__) @@ -21,6 +21,13 @@ class ScaryMovie(commands.Cog): """Randomly select a scary movie and display information about it.""" async with ctx.typing(): selection = await self.select_movie() + if not selection: + await ctx.send(embed=Embed( + title=random.choice(NEGATIVE_REPLIES), + description=":warning: Failed to select a movie from the API", + color=Colours.soft_red + )) + return movie_details = await self.format_metadata(selection) await ctx.send(embed=movie_details) @@ -44,10 +51,16 @@ class ScaryMovie(commands.Cog): total_pages = data.get("total_pages") # Get movie details from one random result on a random page - params["page"] = random.randint(1, total_pages) + params["page"] = random.randint(1, min(total_pages, 500)) async with self.bot.http_session.get(url=url, params=params, headers=headers) as response: data = await response.json() - selection_id = random.choice(data.get("results")).get("id") + if (results := data.get("results")) is None: + log.warning("Failed to select a movie - data returned from API has no 'results' key") + return {} + selection_id = random.choice(results).get("id") + if selection_id is None: + log.warning("Failed to select a movie - selected film didn't have an id") + return {} # Get full details and credits async with self.bot.http_session.get( diff --git a/bot/resources/utilities/ryanzec_colours.json b/bot/resources/utilities/ryanzec_colours.json index 3eff93f2..a118c23a 100644 --- a/bot/resources/utilities/ryanzec_colours.json +++ b/bot/resources/utilities/ryanzec_colours.json @@ -776,6 +776,7 @@ "Lemon Chiffon": "FFFACD", "Lemon Ginger": "AC9E22", "Lemon Grass": "9B9E8F", + "Lesser Yellow": "F1C40F", "Light Apricot": "FDD5B1", "Light Orchid": "E29CD2", "Light Wisteria": "C9A0DC", |