Start of fixes

Rene Teigen 2 years ago
parent a3763e68a1
commit a5d675ff5c

@ -66,7 +66,7 @@ class TextService:
""" """
new_prompt = ( new_prompt = (
prompt + "\n" + BOT_NAME prompt + "\n" + BOT_NAME
if not from_ask_command and not from_edit_command if not from_ask_command and not from_edit_command and not redo_request
else prompt else prompt
) )
@ -191,7 +191,7 @@ class TextService:
prompt_with_history.sort(key=lambda x: x.timestamp) prompt_with_history.sort(key=lambda x: x.timestamp)
# Ensure that the last prompt in this list is the prompt we just sent (new_prompt_item) # Ensure that the last prompt in this list is the prompt we just sent (new_prompt_item)
if prompt_with_history[-1] != new_prompt_item: if prompt_with_history[-1].text != new_prompt_item.text:
try: try:
prompt_with_history.remove(new_prompt_item) prompt_with_history.remove(new_prompt_item)
except ValueError: except ValueError:
@ -420,27 +420,18 @@ class TextService:
custom_api_key=custom_api_key, custom_api_key=custom_api_key,
), ),
) )
converser_cog.redo_users[ctx.author.id] = RedoUser(
if response_message: prompt=new_prompt if not converser_cog.pinecone_service else prompt,
# Get the actual message object of response_message in case it's an WebhookMessage instruction=instruction,
actual_response_message = ( ctx=ctx,
response_message message=ctx,
if not from_context response=response_message,
else await ctx.fetch_message(response_message.id) codex=codex,
) paginator=paginator,
)
converser_cog.redo_users[ctx.author.id] = RedoUser( converser_cog.redo_users[ctx.author.id].add_interaction(
prompt=new_prompt, response_message.id
instruction=instruction, )
ctx=ctx,
message=ctx,
response=actual_response_message,
codex=codex,
paginator=paginator,
)
converser_cog.redo_users[ctx.author.id].add_interaction(
actual_response_message.id
)
# We are doing a redo, edit the message. # We are doing a redo, edit the message.
else: else:
@ -758,6 +749,10 @@ class ConversationView(discord.ui.View):
self.clear_items() self.clear_items()
# Send a message to the user saying the view has timed out # Send a message to the user saying the view has timed out
if self.message: if self.message:
# check if the timeout happens in a thread and if it's locked
if isinstance(self.message.channel, discord.Thread):
if self.message.channel.locked:
return
await self.message.edit( await self.message.edit(
view=None, view=None,
) )

Loading…
Cancel
Save