jishaku icon indicating copy to clipboard operation
jishaku copied to clipboard

[Feature] ReRun py/pyi command if the message is edited

Open CircuitSacul opened this issue 3 years ago • 4 comments

The Problem

Very frequently, I will write a long eval code and come across some error. This means I have to copy+paste my code, fix the error, and then resend it. This is spammy and slow.

The Ideal Solution

After running the py/pyi command, jiskaku will listen for the on_raw_message_edit event for the next 30 seconds on this specific message. If edited, rerun the py/pyi command, and instead of sending new output, edit the original message with the new output.

The Current Solution

Copy+paste the eval command and resend it after fixing.

CircuitSacul avatar May 10 '21 18:05 CircuitSacul

You can do this yourself,

@bot.listen()
async def on_message_edit(before: discord.Message, after: discord.Message):
    if before.content == after.content:
        return
    return await bot.process_commands(after)

You can also limit this to the owner with await bot.is_owner(after.author)

avizum avatar Jun 15 '21 15:06 avizum

No, because that would send a new result, not edit the original result.

CircuitSacul avatar Jun 19 '21 13:06 CircuitSacul

Maybe you can override commands.Context and edit the message with the new content if the message was edited, Not sure though.

avizum avatar Jun 21 '21 04:06 avizum

No, because that would send a new result, not edit the original result.

What if your evaluated code sends multiple messages before erroring? If your code works and sends something when it gets rerun, how show Jishaku know to edit the original message without modifying the Context class? (A custom Context class for Jishaku would conflict with any user-set Context classes, and monkeypatching is not a great solution for production code.)

pythonmcpi avatar Nov 21 '22 06:11 pythonmcpi