I’m trying to update a discord.embed with reaction:
@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")
I create a discord embed with some default information, and add the reaction I want to use, the idea is that when someone react with one of the select reaction, the name of the user is added to the field.
( I actually have 4 commands using the same “template” with the same reaction, and I want them all to work individually)
Advertisement
Answer
You need to use wait_for for this.
Also on_raw_reaction_add takes only one argument that is payload, I believe you are trying to use on_reaction_add
Remove the while loop if you wish to consider only the first reaction that is added
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")