Fix comparison to last message for determining if update required

This commit is contained in:
Adam Goldsmith 2021-05-02 22:44:34 -04:00
parent 3308f3c7f9
commit dfe4be1f6d

View File

@ -68,13 +68,16 @@ class ArkhamDBClient(discord.Client):
return latest_decks
async def clear_old_messages(self, channel: discord.TextChannel) -> None:
async for message in channel.history(limit=200):
if message.author.id == self.user.id and message.id != channel.last_message_id:
await message.delete()
async def update_channel_latest_decks(self, channel: discord.TextChannel) -> None:
deck_ids = await self.gather_deck_ids(channel)
latest_decks = await self.get_latest_decks(deck_ids)
async for message in channel.history(limit=200):
if message.author.id == self.user.id and message.id != channel.last_message_id:
await message.delete()
await self.clear_old_messages(channel)
try:
last_message = await channel.fetch_message(channel.last_message_id)
@ -89,7 +92,7 @@ class ArkhamDBClient(discord.Client):
description=message_text)
if last_message is not None and last_message.author.id == self.user.id:
if len(message.embeds) != 1 or message_text != message.embeds[0].description:
if len(last_message.embeds) == 1 and message_text != last_message.embeds[0].description:
await last_message.edit(embed=message_embed)
else:
await channel.send(embed=message_embed)