简体   繁体   English

如何让不和谐机器人使用 discord.py 向消息添加表情符号反应?

[英]How do I get a discord bot to add an emoji reaction to a message using discord.py?

I have been trying to get a discord bot that can auto react to messages using default emoji, i keep getting error code 10014: Emoji not found.我一直在尝试获得一个可以使用默认表情符号自动对消息做出反应的不和谐机器人,我不断收到错误代码 10014:找不到表情符号。 This is my code:这是我的代码:

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

I am using the discord api, and all other parts of the bot, such as sending and reading messages work fine, but the emojis are the only thing I can't seem to figure out.我正在使用discord api,并且机器人的所有其他部分(例如发送和阅读消息)都可以正常工作,但表情符号是我似乎唯一无法弄清楚的东西。

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

The emoji may be a unicode emoji or a custom guild Emoji.表情符号可以是 unicode 表情符号或自定义公会表情符号。

Unicode Emoji: Unicode 表情符号:

await message.add_reaction("✅")

Or through the Emoji object:或者通过 Emoji 对象:

https://discordpy.readthedocs.io/en/latest/api.html?highlight=reaction#discord.Client.get_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)

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

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