我正在尝试更新一个不和。嵌入反应:
@bot.command()
async def expedition(ctx, expe, date, heure):
embed=discord.Embed(title="Expedition", description= expe + "n" + date + " : " + heure + "nFor " + ctx.message.author.mention, color=0xFF5733)
embed.add_field(name="tank", value="1 slots", inline=True)
embed.add_field(name="heal", value="1 slots", inline=True)
embed.add_field(name="dps", value="3 slots", inline=True)
msg = await ctx.send(embed=embed)
await msg.add_reaction('N{SHIELD}')
await msg.add_reaction('🧑⚕️')
await msg.add_reaction('N{CROSSED SWORDS}')
await msg.add_reaction('❌')
@client.event
async def on_raw_reaction_add(reaction,user):
if reaction.emoji == 'N{SHIELD}':
embed.set_field_at(0,name="tank",value=user.mention)
print("test 1")
if reaction.emoji == '🧑⚕️':
embed.set_field_at(1,name="heal",value=user)
print("2 test")
if reaction.emoji == 'N{CROSSED SWORDS}':
embed.set_field_at(2,name="dps",value=user)
print("D la réponse D")
我用一些默认信息创建了一个不和嵌入,并添加了我想使用的反应,其思想是,当有人响应其中一个选择响应时,用户的名称被添加到字段中。
(实际上我有4个命令使用相同的"模板"有相同的反应,我希望它们都单独工作)
您需要使用wait_for
。
on_raw_reaction_add
也只有一个参数是payload
,我相信你是在尝试使用on_reaction_add
如果只考虑添加的第一个反应,则删除while循环
async def expedition(ctx, expe, date, heure):
embed=discord.Embed(title="Expedition", description= expe + "n" + date + " : " + heure + "nFor " + ctx.message.author.mention, color=0xFF5733)
embed.add_field(name="tank", value="1 slots", inline=True)
embed.add_field(name="heal", value="1 slots", inline=True)
embed.add_field(name="dps", value="3 slots", inline=True)
msg = await ctx.send(embed=embed)
await msg.add_reaction('N{SHIELD}')
await msg.add_reaction('🧑⚕️')
await msg.add_reaction('N{CROSSED SWORDS}')
await msg.add_reaction('❌')
while True:
reaction, user = await client.wait_for("reaction_add", check=lambda reaction, user: reaction.message.id == msg.id)
if reaction.emoji == 'N{SHIELD}':
embed.set_field_at(0,name="tank",value=user.mention)
print("test 1")
if reaction.emoji == '🧑⚕️':
embed.set_field_at(1,name="heal",value=user)
print("2 test")
if reaction.emoji == 'N{CROSSED SWORDS}':
embed.set_field_at(2,name="dps",value=user)
print("D la réponse D")