python - 如何让不和谐机器人使用 discord.py 向消息添加表情符号反应?
问题描述
我一直在尝试获得一个可以使用默认表情符号自动对消息做出反应的不和谐机器人,我不断收到错误代码 10014:找不到表情符号。这是我的代码:
elif message.content == "test":
await message.add_reaction(:white_check_mark:)
我正在使用 discord api,并且机器人的所有其他部分,例如发送和阅读消息都可以正常工作,但表情符号是我唯一无法弄清楚的事情。
解决方案
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)
推荐阅读
- java - 列出 HADOOP 2.x 中映射器和缩减器数量的命令
- node.js - 将 mongodb 对象 ID 设置为“String”而不是“Schema.Types.ObjectId”是不好的做法吗?
- php - 为什么 $_GET 没有从不同的页面获取数据?
- java - 如何提取包含已字符串化为 Java 类的 ISO8385 字段以及匹配字段的 JSON 内容?
- python - 安装 2.7.5 时的段错误
- c++ - 从方法返回 JsonDoc 作为引用
- javascript - 隐藏下拉列表后,单击时再次显示?
- android - 带有导航组件的嵌套片段中的 OptionsMenu
- active-directory - 查看 Umbraco 中的成员部分时出错
- javascript - angularjs中的下拉列表没有被填充