Skip to content

Commit

Permalink
Improve non-successful command cleanup in chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Nov 18, 2024
1 parent 7a73faa commit 0776193
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,13 @@ async def invoke_command(self, ctx: commands.Context, prompt_messages: list, fun
command_ctx.invoked_with = invoker
command_ctx.command = self.bot.all_commands[invoker]
await self.bot.invoke(command_ctx)
async for message in ctx.history(limit=4):
async for message in ctx.history(limit=5):
if message.created_at < ctx.message.created_at:
break
if message.author == ctx.me:
# Found a message which probably resulted from the tool's command invocation
# Found a message which _probably_ resulted from the tool's command invocation
resulting_message_content = await self.message_to_text(command_ctx, message)
if resulting_message_content and resulting_message_content[0] in ("⚠️", "🙁", "❔"):
if message.embeds and message.embeds[0].title[0] in ("⚠️", "🙁", "❔"):
# There was some error, which hopefully we'll correct on next try
await message.delete()
return resulting_message_content, False
Expand Down

0 comments on commit 0776193

Please sign in to comment.