Fix comparison to last message for determining if update required
This commit is contained in:
parent
3308f3c7f9
commit
dfe4be1f6d
11
ahtcg_bot.py
11
ahtcg_bot.py
@ -68,13 +68,16 @@ class ArkhamDBClient(discord.Client):
|
|||||||
|
|
||||||
return latest_decks
|
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:
|
async def update_channel_latest_decks(self, channel: discord.TextChannel) -> None:
|
||||||
deck_ids = await self.gather_deck_ids(channel)
|
deck_ids = await self.gather_deck_ids(channel)
|
||||||
latest_decks = await self.get_latest_decks(deck_ids)
|
latest_decks = await self.get_latest_decks(deck_ids)
|
||||||
|
|
||||||
async for message in channel.history(limit=200):
|
await self.clear_old_messages(channel)
|
||||||
if message.author.id == self.user.id and message.id != channel.last_message_id:
|
|
||||||
await message.delete()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
last_message = await channel.fetch_message(channel.last_message_id)
|
last_message = await channel.fetch_message(channel.last_message_id)
|
||||||
@ -89,7 +92,7 @@ class ArkhamDBClient(discord.Client):
|
|||||||
description=message_text)
|
description=message_text)
|
||||||
|
|
||||||
if last_message is not None and last_message.author.id == self.user.id:
|
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)
|
await last_message.edit(embed=message_embed)
|
||||||
else:
|
else:
|
||||||
await channel.send(embed=message_embed)
|
await channel.send(embed=message_embed)
|
||||||
|
Loading…
Reference in New Issue
Block a user