Deleting Discord DMs without hammering the rate limit
dmcleaner is a small Python script that deletes your own messages in DMs. Calling the delete endpoint is one line. Making it survive thousands of messages is the actual work.
A heads-up first: it needs a user token, and automating a user account can go against Discord's terms. The repo says so, it is irreversible, and I treat it as an educational project. Use it on your own account at your own risk.
Two delays
Discord rate-limits per route and answers 429 when you go too fast. Retrying blindly makes it worse, so the script paces itself with two knobs:
self.channel_delay = 1.2 # wait between channels (seconds)
self.message_delay = 0.25 # wait between messages (seconds)Slow enough to stay under the limit, fast enough that a few thousand messages finish in a sane time.
Retry, don't crash
Pacing is not perfect, so there is also an automatic retry. If Discord still pushes back with a 429, the run waits and tries again instead of dying halfway through a conversation.
Scope
- Clean one conversation by passing a user ID, or every DM.
- Animated, readable logs so you can see progress.
- PyInstaller build script for a Windows exe.
Written with aiohttp, so the waiting does not block anything else. It is on GitHub.