我正在尝试制作一个机器人。这是一个存档机器人。如果某条消息获得了一些表情符号和一些金额,它会将消息移动到用户选择的特定频道。 Bot 运行良好,但存在一个问题:
Bot 无法处理旧消息。例如,想一则消息有 5 次这个表情符号?。机器人必须将此消息移动到选定的频道。但是当消息较旧或消息在 Bot 运行之前时,它不起作用。我必须删除表情符号(制作 4 个表情符号)然后再次添加表情符号(再次制作 5 个)以使 Bot 运行。我该怎么做:机器人正在扫描消息,然后将消息移动到可用条件的频道。我该怎么做?
这是我的代码:
@Bot.event
async def on_raw_reaction_add(payload):
user = Bot.get_user(payload.user_id)
guild = Bot.get_guild(payload.guild_id)
channel = guild.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
veriler()
if payload.emoji.name in veriler.emoji_list:
sıra = veriler.emoji_list.index(payload.emoji.name)
for reaction in message.reactions:
if reaction.emoji == payload.emoji.name:
emojiCount = reaction.count
if emojiCount == veriler.adet[sıra]:
if payload.channel_id != veriler.from_list[sıra]:
return
if message.author.id == Bot.user.id and payload.emoji.name =="✅": #here my way to fix it
return
if payload.message_id in veriler.msg_list:
return
else:
await guild.get_channel(veriler.to_list[sıra]).send("Written by {} :\n\n {}".format(message.author.mention,message.content),files=[await f.to_file() for f in message.attachments])
await guild.get_channel(veriler.from_list[sıra]).send("{} your message moved to this channel --> {}".format(message.author.mention,Bot.get_channel(veriler.to_list[sıra]).mention))
await message.add_reaction("✅")
file5=open("msg_list.txt","a")
msg_id =payload.message_id
msg_id=str(msg_id)
file5.write(msg_id + "\n")
file5.close()