Skip to content

Commit 2af6334

Browse files
fix: add error handling for handle_convo_llm to improve stability
1 parent 25dff91 commit 2af6334

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

bot.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,12 +1871,15 @@ async def on_message(self, message):
18711871

18721872
# Handle Mentions of the Bot
18731873
if self.bot.user.mentioned_in(message):
1874-
await handle_convo_llm(
1875-
message=message,
1876-
user_info=user_info,
1877-
bot=self.bot,
1878-
user_time=message_time,
1879-
)
1874+
try:
1875+
await handle_convo_llm(
1876+
message=message,
1877+
user_info=user_info,
1878+
bot=self.bot,
1879+
user_time=message_time,
1880+
)
1881+
except Exception as e:
1882+
print(f"Error in handle_convo_llm (mention): {e}")
18801883
return
18811884

18821885
# Handle Replies to the Bot
@@ -1886,13 +1889,16 @@ async def on_message(self, message):
18861889
and message.reference.resolved.author == self.bot.user
18871890
and message.channel.id not in [chat_fr, chat_en]
18881891
):
1889-
await handle_convo_llm(
1890-
message=message,
1891-
user_info=user_info,
1892-
bot=self.bot,
1893-
user_time=message_time,
1894-
mess_ref=message.reference,
1895-
)
1892+
try:
1893+
await handle_convo_llm(
1894+
message=message,
1895+
user_info=user_info,
1896+
bot=self.bot,
1897+
user_time=message_time,
1898+
mess_ref=message.reference,
1899+
)
1900+
except Exception as e:
1901+
print(f"Error in handle_convo_llm (reply): {e}")
18961902
return
18971903

18981904
if message.guild.id not in WHITELIST_GUILDS_ID:
@@ -2194,7 +2200,7 @@ async def on_message(self, message):
21942200
await message.channel.send(f"Unexpected error occurred: {e}")
21952201
return
21962202

2197-
if "image message" in message.content.lower():
2203+
if "image message" in message.content.lower(): # Weight GG API shit
21982204
await handle_convo_llm_image(
21992205
message=message,
22002206
user_info=user_info,

0 commit comments

Comments
 (0)