Add reaction to a message (discord.py)

南楼画角 提交于 2021-01-27 19:34:28

问题


I want to add a reaction to a message that gets send in one channel. I get the error code:

discord.errors.InvalidArgument: emoji argument must be str, Emoji, or Reaction not NoneType.

Here is my code:

client = discord.Client()

if message.channel.id == 737668230012862514:
    emoji = client.get_emoji(310177266011340803)
    await message.add_reaction(emoji)

回答1:


The line: emoji argument must be str, Emoji, or Reaction not NoneType indicates that the emoji was set to None, meaning that the client could not find the emoji of id 310177266011340803.

As you can see from the documentation, get_emoji returns None if no emoji was found.

Please make sure that 310177266011340803 is a valid emoji id and that the bot has access to the server where the emoji is.

To access all emoji names and IDs, you can write:

@client.event
async def on_ready():
    for emoji in client.emojis:
        print("Name:", emoji.name + ",", "ID:", emoji.id)


来源:https://stackoverflow.com/questions/63137643/add-reaction-to-a-message-discord-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!