How to monitor message edits in Discord bot when messages were sent during bot downtime

I’m working on a Discord bot using discord.py that needs to track changes in messages with embeds that get updated regularly. Everything works fine when my bot is running and online during the initial message posting. But I’m running into issues when my bot restarts or goes offline temporarily.

The problem is that the on_message_edit event doesn’t trigger for messages that were posted while my bot wasn’t connected to the server. I tried using Channel.history() to grab older messages, but the edit detection still doesn’t work for those.

From what I’ve read, this happens because these messages aren’t stored in the bot’s internal cache. I looked through the documentation but couldn’t find a clear way to force older messages into the cache system.

I know about TextChannel.fetch_message(id) but this doesn’t seem to add the message to the cache from my testing. Is there a way to make the bot monitor edits for messages that were sent before it came online? Any suggestions would be really helpful.

honestly this is why i switched to storing message hashes instead of full content. when bot comes back online just hash the current messages and compare - way lighter than storing snapshots and you’ll catch any edits that happend during downtime. not perfect but works decent enough

I know, right? It’s so frustrating! If you really need to track those edits, maybe consider saving a snapshot of messages when they’re sent. That way, you can compare later when the bot is back online. It’ll take some extra coding, but could save you headaches!

Indeed, this is a known limitation with Discord’s caching system. The on_message_edit event will not trigger for messages that were sent while your bot was offline, as those messages aren’t present in the bot’s cache. To overcome this, consider implementing a method to log message data to a database or local storage as your bot runs. When it reconnects, you can utilize the channel.history() to collect messages, compare them with your logs, and identify any edits that took place during the downtime. Although this approach requires additional resources, it can effectively provide the tracking you need.

Been there, done that. This exact scenario killed my productivity tracking bot last year.

The real issue isn’t caching - you’re trying to patch an infrastructure problem with code. You need something that stays online and handles Discord’s API separately from your main bot.

I moved all my message monitoring to an external automation platform. Set up workflows that watch Discord channels through webhooks and API calls. When messages get edited, automation catches it instantly and processes changes - doesn’t matter if my main bot’s down.

This runs 24/7 in the cloud, so you never miss edits during downtime. You can trigger actions in your main bot when it comes back online, or send data wherever you need it.

I store all message snapshots and edit history in a database both the automation and bot can access. Clean separation.

Check out Latenode for this setup - handles Discord’s API well and uptime’s solid: https://latenode.com

You’re hitting a core Discord API limitation that can’t really be fixed client-side. I’ve dealt with this in production - periodic message validation beats trying to hack cache behavior. Here’s what works: Run a scheduled task every few minutes while your bot’s online. Fetch messages from target channels using their IDs (save these when first posted) and compare current content against your stored versions. When you find differences, trigger the same logic from your edit handler. The key insight? Treat this as polling, not event-driven, for messages posted before bot startup. You’ll need persistent storage to track monitored messages anyway, so storing content snapshots adds minimal overhead. This handles downtime and protects against missed events during network issues. Performance impact is tiny if you batch the API calls right.