Delete last X messages from user for moderation
Problem: Sometimes you have a lot of messages from a user, that might not be appropriate or against the rules. Folks who write texts in smaller lengths, it can pile up to an "annoying no of deletes"
Possible solution: Introduction of new command "/delete user nNoOfMessages", which deletes the most n messages from given user.
In most cases that warrant mass-message-deletion, a (temporary) ban is warranted as well. Bans (including temp bans) already provide the functionality to purge messages.
But I still see how the command could be useful. Id advice to instead follow the UX of /ban and add options to purge messages based on time, not amount. For example:
- last hour
- last day
- last 7 days
And to rename it to /purge, which is more idiomatic. In fact, there are some duplicates already: #17 #218 #238 #330
As you see, this command has been attempted thrice already 😆
Interesting, I wonder what prevented the completion maybe too complex or scope not defined clearly?
Btw i was wondering about the implementation part, I have explored it a bit. I don't have exact implementation ideas atm but I think i might need to work with
I suppose I can get current instance of time and pull messages in bulk then filter based on a particular user and upto a certain interval . And finally do the delete operation. Thoughts?
The issue is that you have to retrieve hundreds if not thousands of messages from every channel, this command never got added because of rate limits.
There is no way to delete all messages sent in the last week, last hour already sounds overkill.
When implementing this, make sure to only retrieve from channels that the user has access to & can write to, otherwise you're wasting the limited history we can retrieve
Personally I'd say that the best implementation is to forward EVERY message to an SQL database, and then retrieve what messages have to be deleted from that.
But even then, deleting messages also got rate limited pretty harshly a year ago, I don't know how the current situation is. You can attempt this, but you really need to benchmark the rate limits before implementing.
Well in that case it might be unnecessary to delete messages upto a day or week , like zabu mentioned "deleting that many messages might require a ban instead". But i totally see how "upto 1 hour" mark can be useful.
This is what i have atm, as per suggestions i have decided to only to delete messages upto an hour.
- Listener which writes all message records to DB when recieved
- Routine that clears message records from DB if it's older than an hour or so
-
/purgecommand which has two optionsuserandreason, reads ID's from DB, stores into a list.
For bulk deletion, this seems good.
Thoughts?
Edit: deleting messages from every channel seems pointless, since if someone is being a problem in more than one channel i don't think they're human and if they are they deserve a temp ban at that point. So this command will purge messages from the channel where it's used.