bot
bot copied to clipboard
Add trash option to all bot responses
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.
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.
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
.
Maybe that could work.
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?
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.
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?
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)