尝试检查wait_for反应是否是某种表情符号

时间:2019-06-25 19:13:46

标签: python discord.py discord.py-rewrite

我正在尝试检查我的wait_for返回值是否是某种表情符号。

我尝试过str(one.reaction.emoji),我尝试过one.reaction.emoji

charm = discord.Embed(description=f"React With The Corresponding Emoji, What You Wish To Edit.", color=0xff89ff)
charm.set_author(name=f"{user.name}")
charm.set_thumbnail(url=str(user.avatar_url))
charm.add_field(name="Name", value=":one:")
charm.add_field(name="Sexual Preference", value=":two:")
charm.add_field(name="Biography", value=":three:")
charm.add_field(name="Hobbies", value=":four:")
charm.add_field(name="Location", value=":five:")
editmsg = await user.send(embed=charm)
await editmsg.add_reaction(emoji="1\N{combining enclosing keycap}")
await editmsg.add_reaction(emoji="2\N{combining enclosing keycap}")
await editmsg.add_reaction(emoji="3\N{combining enclosing keycap}")
await editmsg.add_reaction(emoji="4\N{combining enclosing keycap}")
await editmsg.add_reaction(emoji="5\N{combining enclosing keycap}")
one = bot.wait_for("reaction_add", check=onecheck)

if str(one.reaction.emoji) == "1\N{combining enclosing keycap}":
await user.send("What Do You Wish To Change Your Name To?")

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

try:
    reaction, user = await bot.wait_for('reaction_add', timeout=30.0)
except asyncio.TimeoutError:
    await user.send('I did not receive your reaction :(')
else:
    if str(reaction.emoji) == '?':
        await user.send('Haha')
    if str(reaction.emoji) == '?':
        await user.send('Say something')
    if str(reaction.emoji) == '?':
        await user.send('and so on')
    ...