Daily
Clear out old messages every night
Busy channels like bot logs stay short, with messages older than a week removed.
- Runs
- Daily
- Apps
- Discord
- AI
- Not needed
- Access
- Read Message History, Manage Messages
Send this to your assistant
Create a ClickRuntime automation: every night at 9pm, delete messages older than 7 days in #bot-logs on my Discord.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A server with a high-traffic support or bot-output channel fills with messages that stop being useful within days: old command results, stale announcements, temporary chat. Scrolling gets slower, new members stumble on outdated instructions, and screenshots of personal details stay around for months. Deleting messages by hand is tedious, and Discord's own tools only offer bulk deletion for recent messages.
Each night the automation lists the channels you named, pages through their messages and deletes any older than the number of days you set, such as seven. It pauses between deletions to respect Discord's rate limits, so a large backlog is cleared gradually without errors. By morning the channel holds only recent, relevant messages, and nobody had to stay up for it.
Servers with bot logs, trade channels or support queues find it most useful.
What you get out of it
Channels that stay short and readable
A week of history is enough for most conversations. Newcomers see current messages instead of a wall of stale ones, and scrolling back to find something stays quick instead of becoming slower with every month that passes.
Old personal details do not linger
Messages containing emails, usernames or screenshots disappear on schedule. That reduces what could be exposed if the server is ever compromised, and it fits with a sensible habit of not keeping personal information longer than it is needed.
Outdated instructions stop misleading people
Obsolete help messages are removed instead of being found and followed months later by someone who did not know they were out of date. Support staff spend less time correcting advice that was right last spring and wrong today.
No manual cleanup chore
A moderator no longer needs to remember to clear bot-output channels by hand. The work happens at night when no one is chatting, so the clearing never interrupts a conversation or surprises anyone mid-sentence.
Rate-limit safe deletion
Pausing between deletions avoids errors from Discord, so a large backlog is handled steadily over a night instead of failing partway. If a run is interrupted, the next night picks up whatever is left without anyone intervening.
How it works
What happens, step by step
Every night, ClickRuntime goes through the messages in the Discord channel you chose.
It finds messages older than the number of days you set.
It deletes them, pausing as needed so Discord does not block the bot.
A note is posted saying how many messages were removed.
Before it runs live
- Connect Discord
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Discord steps into one automation
Under the hood
The code that runs this automation
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, http, credentials
BOT_LOGS = "BOT_LOGS_CHANNEL_ID"
def discord(method, path, **kw):
r = http.request(method, f"https://discord.com/api/v10{path}",
headers={"Authorization": f"Bot {credentials.secret('DISCORD_BOT_TOKEN')}"}, **kw)
r.raise_for_status()
return r.json() if r.content else None
@on_trigger
def run(event):
now = datetime.now(timezone.utc)
msgs = discord("GET", f"/channels/{BOT_LOGS}/messages", params={"limit": 100})
old = [m for m in msgs if datetime.fromisoformat(m["timestamp"]) < now - timedelta(days=7)]
bulk = [m["id"] for m in old if datetime.fromisoformat(m["timestamp"]) > now - timedelta(days=14)]
if len(bulk) >= 2:
discord("POST", f"/channels/{BOT_LOGS}/messages/bulk-delete", json={"messages": bulk})
for m in old:
if m["id"] not in bulk or len(bulk) < 2:
discord("DELETE", f"/channels/{BOT_LOGS}/messages/{m['id']}")
return {"deleted": len(old)}FAQ
Common questions
Does it delete pinned messages?
Can I choose how many days to keep?
What permissions does the bot need?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Get told when an item is back in stock
Your server hears the moment a product page changes, like a sold-out item coming back.
See how it worksPost a weekly announcement in Discord
The same reminder goes out on time every week without anyone remembering to post it.
See how it worksGet a weekly report on your community
Every Monday your mods see who joined and which channels were busiest, compared with the week before.
See how it worksKeep exploring
Set up “Clear out old messages every night” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.