Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CircuitSacul opened this issue May 10, 2021 · 4 comments
Open

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

CircuitSacul opened this issue May 10, 2021 · 4 comments

Comments

@CircuitSacul
Copy link

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.

@avizum
Copy link

avizum commented Jun 15, 2021

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)

@CircuitSacul
Copy link
Author

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

@avizum
Copy link

avizum commented Jun 21, 2021

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

@pythonmcpi
Copy link
Contributor

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants