store message.id instead of message in reroll history
This commit is contained in:
14
bot.py
14
bot.py
@@ -44,7 +44,7 @@ async def discord_send(channel, text, name, avatar=DEFAULT_AVATAR):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
message = await channel.send(content=chunk)
|
message = await channel.send(content=chunk)
|
||||||
messages.append(message)
|
messages.append(message.id)
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
async def webhook(channel):
|
async def webhook(channel):
|
||||||
@@ -102,14 +102,22 @@ async def on_reaction_add(reaction, user):
|
|||||||
message = reaction.message
|
message = reaction.message
|
||||||
channel = message.channel
|
channel = message.channel
|
||||||
conversation = await Conversation.get(channel.id)
|
conversation = await Conversation.get(channel.id)
|
||||||
if message not in conversation.last_messages:
|
if message.id not in conversation.last_messages:
|
||||||
await reaction.clear()
|
await reaction.clear()
|
||||||
return
|
return
|
||||||
print(f"_ {user}: {reaction}")
|
print(f"_ {user}: {reaction}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with channel.typing():
|
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()
|
await message.delete()
|
||||||
response = await conversation.regenerate()
|
response = await conversation.regenerate()
|
||||||
conversation.last_messages = await discord_send(
|
conversation.last_messages = await discord_send(
|
||||||
|
Reference in New Issue
Block a user