From 8437cc69401363ae27836a868026d8273796b4eb Mon Sep 17 00:00:00 2001 From: Dory Date: Thu, 21 Aug 2025 10:36:14 -0700 Subject: [PATCH] store message.id instead of message in reroll history --- bot.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index f1899ba..d847ba7 100644 --- a/bot.py +++ b/bot.py @@ -44,7 +44,7 @@ async def discord_send(channel, text, name, avatar=DEFAULT_AVATAR): ) else: message = await channel.send(content=chunk) - messages.append(message) + messages.append(message.id) return messages async def webhook(channel): @@ -102,14 +102,22 @@ async def on_reaction_add(reaction, user): message = reaction.message channel = message.channel conversation = await Conversation.get(channel.id) - if message not in conversation.last_messages: + if message.id not in conversation.last_messages: await reaction.clear() return print(f"_ {user}: {reaction}") try: async with channel.typing(): - for message in conversation.last_messages: + try: + messages = [ + await channel.fetch_message(message_id) + for message_id in conversation.last_messages + ] + except (discord.NotFound, discord.Forbidden): + # don't do anything if any message in the list is not found + await reaction.clear() + for message in messages: await message.delete() response = await conversation.regenerate() conversation.last_messages = await discord_send(