如何获得 wait_for("reaction_add") 的反应
How to get reaction from wait_for("reaction_add")
我正在 discord.py 中开发一个小的反应角色机器人 - 为此,我尝试使用带有“reaction_add”参数的 .wait_for() 函数。问题是我需要从反应中获取表情符号,但由于显示错误而无法正常工作:
AttributeError: 'tuple' object has no attribute 'user'
貌似我尝试获取表情符号的方式有问题,但我找不到正确的获取表情符号的方法。
interaction = await client.wait_for('reaction_add')
if interaction.emoji == "":
await interaction.user.add_roles(role)
emoji = ""
message = await ctx.send("Test")
await message.add_reaction(emoji)
reaction, user = await bot.wait_for("reaction_add")
if user != bot.user:
if reaction.emoji == emoji:
await user.add_roles(user, role)
或
emoji = ""
def check(reaction, user):
return user == ctx.message.author and reaction.emoji == emoji
message = await ctx.send("Test")
await message.add_reaction(emoji)
reaction, user = await bot.wait_for("reaction_add", check=check)
await bot.add_roles(user, role)
我正在 discord.py 中开发一个小的反应角色机器人 - 为此,我尝试使用带有“reaction_add”参数的 .wait_for() 函数。问题是我需要从反应中获取表情符号,但由于显示错误而无法正常工作:
AttributeError: 'tuple' object has no attribute 'user'
貌似我尝试获取表情符号的方式有问题,但我找不到正确的获取表情符号的方法。
interaction = await client.wait_for('reaction_add')
if interaction.emoji == "":
await interaction.user.add_roles(role)
emoji = ""
message = await ctx.send("Test")
await message.add_reaction(emoji)
reaction, user = await bot.wait_for("reaction_add")
if user != bot.user:
if reaction.emoji == emoji:
await user.add_roles(user, role)
或
emoji = ""
def check(reaction, user):
return user == ctx.message.author and reaction.emoji == emoji
message = await ctx.send("Test")
await message.add_reaction(emoji)
reaction, user = await bot.wait_for("reaction_add", check=check)
await bot.add_roles(user, role)