fix: Ensure formatted message is defined for processing attachments, emojis, and stickers

This commit is contained in:
Slipstream 2025-05-27 22:53:57 -06:00
parent 6881dd4737
commit 87e0fe0340
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -899,14 +899,16 @@ async def get_ai_response(cog: 'GurtCog', message: discord.Message, model_name:
if contents[i].role == "user":
current_user_content_index = i
break
# Ensure formatted_current_message is defined for the current message processing
# This will be used for attachments, emojis, and stickers for the current message.
formatted_current_message = format_message(cog, message)
if message.attachments and current_user_content_index != -1:
print(f"Processing {len(message.attachments)} attachments for current message {message.id}")
attachment_parts_to_add = [] # Collect parts to add to the current user message
# Fetch the formatted message data to get the descriptions generated earlier
# This avoids duplicating the description generation logic here
formatted_current_message = format_message(cog, message) # Pass cog
# Fetch the attachment descriptions from the already formatted message
attachment_descriptions = formatted_current_message.get("attachment_descriptions", [])
desc_map = {desc.get("filename"): desc for desc in attachment_descriptions}