From b3639afb62367518ab72dbc6b25d1cd12b587cb0 Mon Sep 17 00:00:00 2001 From: "Karina J. Kwiatek" Date: Fri, 16 Aug 2024 10:48:19 +0200 Subject: [PATCH] Handle messages no longer existing in `remove_subscribed_message` Co-authored-by: Will Barber --- src/bot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bot.py b/src/bot.py index cbe408a..49512d4 100644 --- a/src/bot.py +++ b/src/bot.py @@ -234,9 +234,10 @@ async def remove_subscribed_message(self, msg: SubscribedMessage) -> None: return message = await msg_channel.fetch_message(msg.message_id) - chan_name = message.channel.name if hasattr(message.channel, 'name') else 'unknown channel' - print(f'Removing message in {chan_name} from {message.author.name}') - await message.delete() # remove message from discord + if message: # message may have already been deleted manually + chan_name = message.channel.name if hasattr(message.channel, 'name') else 'unknown channel' + print(f'Removing message in {chan_name} from {message.author.name}') + await message.delete() # remove message from discord # remove message from subscription list and save to file self.subscribed_messages.remove(msg)