简体   繁体   English

Discord.py 如果语句表情符号不继续

[英]Discord.py if statement emoji not continuing

So I have a problem, where I have my if statement, which should absolutely work but it does not.所以我有一个问题,我有我的 if 语句,它应该绝对有效,但它没有。

Here is the code:这是代码:

@client.event
async def on_raw_reaction_add(payload):
    if payload.channel_id == xxxx:
        print(payload.emoji)
        if payload.emoji == "🆗":
            print('test')

So this should work because payload.emoji returns this:所以这应该有效,因为 payload.emoji 返回这个:

🆗

How could I fix this issue?我该如何解决这个问题?

Okay, so I have just found the error.好的,所以我刚刚发现了错误。

You have to write payload.emoji.name not payload.emoji .你必须写payload.emoji.name而不是payload.emoji

That's all.就这样。

To add more explanation: on_reaction_add provides a Reaction object.添加更多解释: on_reaction_add 提供了一个Reaction对象。 Reaction.emoji returns the associated Emoji object, and the Emoji's Unicode representation can be retrieved with Emoji.name . Reaction.emoji返回关联的Emoji对象,可以使用Emoji.name检索 Emoji 的 Unicode 表示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM