【发布时间】:2021-09-04 10:41:13
【问题描述】:
我正在尝试制作一个机器人。这是一个存档机器人。如果某条消息获得了一些表情符号和一定数量,它会将消息移动到用户选择的特定频道。
但是我有一个问题:如果反应是✅并且反应用户是机器人,它必须不向频道发送消息。我试图在这里做一个检查声明。如果机器人看到这些,它必须无法处理此消息,因为这意味着他之前移动了消息。
这是我的代码:
@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()
当我这样做时,Bot 再次发送消息。它不必这样做,因为我添加了语句。我该如何解决这个问题?
【问题讨论】:
标签: discord.py