bot icon indicating copy to clipboard operation
bot copied to clipboard

reply to user when using !eval/!timeit command instead of pinging

Open e1pupper opened this issue 2 years ago • 7 comments

Closes #2382

Just needed to change ctx.send to ctx.reply and remove the author.mention.

e1pupper avatar Feb 14 '23 10:02 e1pupper

bot/issues/2382

Just needed to change ctx.send to ctx.reply and remove the author.mention.

What if the response gets redirected to a different channel? @redirect_output() doesn't change the behavior of ctx.reply() so the result won't be redirected when it should. It may be worth considering having @redirect_output() add an extra bool attribute (maybe redirected?) for whether or not the output was redirected or maybe even replacing the ctx.reply() function to send a message to the redirected channel instead (not sure if replacing ctx.reply() would be a good idea though).

n0Oo0Oo0b avatar Feb 14 '23 13:02 n0Oo0Oo0b

bot/issues/2382 Just needed to change ctx.send to ctx.reply and remove the author.mention.

What if the response gets redirected to a different channel? @redirect_output() doesn't change the behavior of ctx.reply() so the result won't be redirected when it should. It may be worth considering having @redirect_output() add an extra bool attribute (maybe redirected?) for whether or not the output was redirected or maybe even replacing the ctx.reply() function to send a message to the redirected channel instead (not sure if replacing ctx.reply() would be a good idea though).

I just looked into the @redirect_output() i think it's also sensibile to change those to .reply() as well

            if ping_user:
                await ctx.send(f"Here's the output of your command, {ctx.author.mention}")
            scheduling.create_task(func(self, ctx, *args, **kwargs))

            message = await old_channel.send(
                f"Hey, {ctx.author.mention}, you can find the output of your command here: "
                f"{redirect_channel.mention}"
            )

e1pupper avatar Feb 14 '23 13:02 e1pupper

I just looked into the @redirect_output() i think it's also sensibile to change those to .reply() as well

You can only reply to messages in the same channel, so if this message gets redirected to another channel (such as bot-commands in this case) the message in bot-commands you can no longer reply to the original message.

ChrisLovering avatar Feb 19 '23 15:02 ChrisLovering

We need to handle the case where the message is deleted before the bot sends the response. Currently an error is raised: image To reproduce, run !e import time;time.sleep(5) and immediately delete your message.

There are three main options I can think of for handling this case:

  1. Catch the error and send no response
  2. Catch the error and resend the message with a ping instead of a reply
  3. Make it so the error isn't raised and the message is just sent without being a reply (and without a ping). (I can't remember exactly how you do this, something to do with https://discordpy.readthedocs.io/en/stable/api.html?highlight=reply#discord.Message.to_reference with fail_if_not_exists=False).

I don't have much of a preference given this is an edge case.

i see im gonna see if i can work on this in the weekend sorry for the late response

e1pupper avatar Feb 23 '23 00:02 e1pupper

So, what's the planned behavior for redirected output? Since those can't reply to the original message. Perhaps a link button in the original !eval that links to the message in #bot-commands, and a link button in the result message sent in #bot-commands, that links back to the original !eval command?

Robin5605 avatar Mar 03 '23 15:03 Robin5605

Oh, and also, @e1pupper had noticed us that they will not be able to work on this. I'd be willing to take this up.

Robin5605 avatar Mar 03 '23 15:03 Robin5605

I'd be willing to take this up.

Sounds good, i've assigned you

wookie184 avatar Mar 03 '23 23:03 wookie184

I'll take this over. If the response is redirected I'll just keep the old behaviour of mentioning the user.

wookie184 avatar Apr 02 '24 11:04 wookie184

Since the conflicts are due to the entire snekbox.py file being split up, as this PR is fairly small, I'm just going to start over on a new branch.

wookie184 avatar Apr 02 '24 16:04 wookie184