bot icon indicating copy to clipboard operation
bot copied to clipboard

Allow evaling code from context menus

Open Robin5605 opened this issue 3 years ago • 1 comments

Closes #2270 Pretty simple change. None of the internals have been tweaked. A new context menu with type 3 has been added that will allow for users to eval their or someone else's code (this is new) with the press of a button.

Robin5605 avatar Sep 02 '22 23:09 Robin5605

We wouldn't want, for example, for someone to eval a message from 10 hours ago, especially in help channels

You're right, we wouldn't. We could probably add some config option for this in config.yml or similar, but I think 2 minutes seems reasonable. As for the message popping up without any context, not necessarily. You can see which user ran the command, and you can click on it to be taken back to the original message that eval was ran on.

Since the input message might not have the !eval command invocation, it might be a better UI to reply to the input message (should it still do that for normal invocations?).

This is another slight design issue. Due to the nature of context menus, it can technically be ran on any message, even ones that don't have any code blocks or any code at all. We have a few options here:

  • Parse for code block, and if there is none, just use the message content as code to evaluate. If the command is ran on a random message, e.g "Hello people of Python Discord! I'm new to this community 😄 ", the bot would try to eval this and come up with a syntax error.
  • We can forcefully look for a code block, and throw an error if there is none. Something along the lines of "this message doesn't have a code block"

Another is limiting a user to eval only their own messages, and posting an ephemeral message if they try otherwise.

I'm not really sure on this one. I don't see any immediate downsides if someone were to try to eval someone else's code. The result would be ephemeral, and no damage is done.

If I'm missing anything important here, please do let me know. Cheers 🎉

Robin5605 avatar Sep 13 '22 17:09 Robin5605

I'm not really sure on this one. I don't see any immediate downsides if someone were to try to eval someone else's code. The result would be ephemeral, and no damage is done.

What do you mean by "the result would be ephemeral"? Anyone can see the output right?

mbaruh avatar Oct 18 '22 17:10 mbaruh

I think we still need to decide if this is something we want, and how it should work, so i'll mark this as stalled until there's a consensus on the issue, or on the server/in a staff meeting.

wookie184 avatar Jan 15 '23 10:01 wookie184

What do you mean by "the result would be ephemeral"? Anyone can see the output right?

@mbaruh: No, the resultant message would be only visible to the person who ran the command. So it shouldn't add any clutter for anybody else in the channel as well.

Robin5605 avatar Feb 28 '23 03:02 Robin5605

As for the viability of the feature itself - I'm not entirely sure it's really an improvement over the existing !eval command. There are limitations and I don't see a context menu fixing a major problem that the !eval command already has. I would not be averse to just closing the issue.

Robin5605 avatar Feb 28 '23 03:02 Robin5605