Fix missing message id from channel
Sometimes, last_message_id points to a message in a channel that is "not found". This is OK because we're just figuring out when the last message was sent, and we use the current time instead. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -157,8 +157,13 @@ class Client(discord.Client):
|
|||||||
# NOTE: there is a channel.last_message property, but it's unreliable.
|
# NOTE: there is a channel.last_message property, but it's unreliable.
|
||||||
# fetch_message(last_message_id) will always yield a
|
# fetch_message(last_message_id) will always yield a
|
||||||
# message if there's a valid ID
|
# message if there's a valid ID
|
||||||
message = await channel.fetch_message(channel.last_message_id)
|
try:
|
||||||
self.set_last_tracked_message(channel.id, message.created_at)
|
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):
|
async def on_message(self, message: discord.Message):
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
|
|||||||
Reference in New Issue
Block a user