From 024bfde8a684ff200bc0b181fd16f37795f20c22 Mon Sep 17 00:00:00 2001 From: Paillat Date: Fri, 5 May 2023 16:20:30 +0200 Subject: [PATCH] fix(makeprompt.py): add try-except block to handle errors when sending warning message if guild_data["images_limit_reached"] is True --- code/makeprompt.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/code/makeprompt.py b/code/makeprompt.py index ddac059..cdc4198 100644 --- a/code/makeprompt.py +++ b/code/makeprompt.py @@ -496,12 +496,15 @@ async def gpt_prompt(bot, messages, message, data_dict, prompt, guild_data): await message.channel.trigger_typing() response = response.choices[0].message.content - if guild_data["images_limit_reached"]: - hist = await historicator(message) - await hist.send( - f"```diff\n-Warning: You have reached the image limit for this server. You can upgrade to premium to get more images recognized. More info in our server: https://discord.gg/sxjHtmqrbf```", - delete_after=10, - ) + try: + if guild_data["images_limit_reached"]: + hist = await historicator(message) + await hist.send( + f"```diff\n-Warning: You have reached the image limit for this server. You can upgrade to premium to get more images recognized. More info in our server: https://discord.gg/sxjHtmqrbf```", + delete_after=10, + ) + except: + pass return response