Closed fosspill closed 3 years ago
It would be a useful feature and should be easy to implement. I'm imagining it as a parameter specifying the minimum age to qualify for deletion, like --minage 30d
.
Discord's API supports querying by before/after a timestamp I think so it wouldn't be detrimental to the total query count.
Also, this probably eliminates the need for #18. Interactive deletion would be too much manual labour.
I agree that --minage
(and maybe --maxage
for some reason?) would be great parameters.
Would you happen to have any pointers about where I should start looking if I'd like a go at implementing this? I'm completely new to the language and API, so my success isn't guaranteed however. And of course, if you would rather just work on it and push it out that's more than understandable.
I think a starting point would be to query the API with the constraints we're talking about (min/max age). You can skip adding a CLI parameter and hardcode things to begin with.
Discord's /search
endpoint takes two relevant query parameters:
&min_id
&max_id
These IDs are Snowflakes (see Discord docs) constructed from a timestamp. If you open Discord and search a conversation with before:
or after:
you'll see those query parameters show up in the request.
You could try implementing the Snowflake algorithm in a language you're familiar with first and then translate it.
Hope this helps.
There's some code to this on master
now, but I need to do some quality checks before it is released.
--min-age-days
and --max-age-days
have been added in 1.5.1.
I've read a bit on the documentation and didn't see any way of accomplishing this.
Is it possible to run this program but retain messages the last X days?
The use case would be to regularly clean up old messages in small batches, which would likely reduce your chance of bans as well.