diff --git a/discord_markov/client.py b/discord_markov/client.py index 1e66607..2001259 100644 --- a/discord_markov/client.py +++ b/discord_markov/client.py @@ -157,8 +157,13 @@ class Client(discord.Client): # NOTE: there is a channel.last_message property, but it's unreliable. # fetch_message(last_message_id) will always yield a # message if there's a valid ID - message = await channel.fetch_message(channel.last_message_id) - self.set_last_tracked_message(channel.id, message.created_at) + try: + message = await channel.fetch_message(channel.last_message_id) + last_message = message.created_at + except discord.errors.NotFound: + # sometimes the last message is just not found. What to heck?? + last_message = util.utcnow() + self.set_last_tracked_message(channel.id, last_message) async def on_message(self, message: discord.Message): if message.author.bot: