bot icon indicating copy to clipboard operation
bot copied to clipboard

Add trash option to all bot responses

Open gustavwilliam opened this issue 4 years ago • 7 comments

Issue

When using a command like !rule [rules...] or !pep <pep_number>, there is no way for the user to delete the response sent by the bot.

This is would be relevant when entering the wrong argument (for example !rule 4 instead of !rule 5), you just want to check something real quick or you get the output wasn't what you expected.

Proposed solution

Add a "trash can" reaction to let the user delete the response from the bot. This would be the default for all commands, with the option to disable it for specific commands.

A possible way of specifying that a command should not have the trash option would be using a decorator. Something like @not_deletable or @no_trash would be used for the commands.

We already have the trash functionality implemented in many commands, so this is just a matter of making it more general.

gustavwilliam avatar Aug 30 '20 00:08 gustavwilliam

The function used for messages such as the codeblock auto-responder is implemented here. It's used in the auto-responder here,

We'd have to somehow apply that function to all messages, and then add a decorator for messages we don't want to be deleted.

ghost avatar Aug 30 '20 15:08 ghost

The only way I see a decorator working is if the command returns the message it sends so that the decorator can retrieve it and call wait_for_deletion.

MarkKoz avatar Aug 31 '20 23:08 MarkKoz

Maybe that could work.

gustavwilliam avatar Sep 01 '20 08:09 gustavwilliam

Prematurely hit send and close issue.

I think another option would be to make the decorator add a variable or similar to the command function, that will be passed forward to the function that handles the trash option.

Would this be possible?

gustavwilliam avatar Sep 01 '20 09:09 gustavwilliam

I see @MarkKoz's way working better, because then we could just add an @deleteable or @trashable decorator and would not have to completely modify the bot's message-sending functionality. It just seems simpler to implement this that way.

ghost avatar Sep 05 '20 23:09 ghost

Using a decorator feels confusing (because it's less direct and relies on return values, which is kind of implicit). Furthermore, I think it's redundant. Is it really a worthwhile design to save a single function call?

MarkKoz avatar Sep 21 '20 05:09 MarkKoz

It is possible to implement a custom context class, and overwrite the send method. We could keep all of the methods the same, but add a custom kwarg to send, and default it to be awaited deletable.

await ctx.send('hello user!', not_trashable=True)

onerandomusername avatar Dec 13 '21 01:12 onerandomusername