【问题标题】:How do I get a discord bot to add an emoji reaction to a message using discord.py?如何让不和谐机器人使用 discord.py 向消息添加表情符号反应?
【发布时间】:2020-06-29 09:40:23
【问题描述】:

我一直在尝试获取一个可以使用默认表情符号自动响应消息的不和谐机器人,但我不断收到错误代码 10014:找不到表情符号。这是我的代码:

elif message.content == "test":
    await message.add_reaction(:white_check_mark:)

我正在使用 discord api,机器人的所有其他部分(例如发送和阅读消息)都可以正常工作,但表情符号是我似乎唯一想不通的东西。

【问题讨论】:

    标签: python discord


    【解决方案1】:

    https://discordpy.readthedocs.io/en/latest/api.html?highlight=reaction#discord.Message.add_reaction

    表情符号可以是 unicode 表情符号或自定义公会表情符号。

    Unicode 表情符号:

    await message.add_reaction("✅")
    

    或者通过 Emoji 对象:

    https://discordpy.readthedocs.io/en/latest/api.html?highlight=reaction#discord.Client.get_emoji

    emoji = client.get_emoji(123456)
    await message.add_reaction(emoji)
    

    【讨论】:

      猜你喜欢
      • 2022-01-05
      • 2022-01-05
      • 2021-09-04
      • 2020-10-11
      • 2021-05-14
      • 2018-08-05
      • 1970-01-01
      • 2021-05-24
      • 2021-10-12
      相关资源
      最近更新 更多