Fix accidental deleting/updating of messages with no embed

This commit is contained in:
Adam Goldsmith 2021-05-03 00:36:04 -04:00
parent 480d234c0c
commit 196d69da51
1 changed files with 7 additions and 3 deletions

View File

@ -60,7 +60,9 @@ class ArkhamDBUpdater(commands.Bot):
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:
if message.author.id == self.user.id \
and message.id != channel.last_message_id \
and len(message.embeds) == 1:
await message.delete()
async def update_channel_latest_decks(self, channel: discord.TextChannel) -> None:
@ -81,8 +83,10 @@ class ArkhamDBUpdater(commands.Bot):
title=f'Updated as of {datetime.now()}',
description=message_text)
if last_message is not None and last_message.author.id == self.user.id:
if len(last_message.embeds) == 1 and message_text != last_message.embeds[0].description:
if last_message is not None \
and last_message.author.id == self.user.id \
and len(last_message.embeds) == 1:
if message_text != last_message.embeds[0].description:
await last_message.edit(embed=message_embed)
else:
await channel.send(embed=message_embed)