bot
bot copied to clipboard
reply to user when using !eval/!timeit command instead of pinging
Closes #2382
Just needed to change ctx.send to ctx.reply and remove the author.mention.
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).
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 ofctx.reply()so the result won't be redirected when it should. It may be worth considering having@redirect_output()add an extra bool attribute (mayberedirected?) for whether or not the output was redirected or maybe even replacing thectx.reply()function to send a message to the redirected channel instead (not sure if replacingctx.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}"
)
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.
We need to handle the case where the message is deleted before the bot sends the response. Currently an error is raised:
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:
- Catch the error and send no response
- Catch the error and resend the message with a ping instead of a reply
- 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
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?
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.
I'd be willing to take this up.
Sounds good, i've assigned you
I'll take this over. If the response is redirected I'll just keep the old behaviour of mentioning the user.
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.
To reproduce, run