Python机器人,增加反应

时间:2018-12-12 23:31:03

标签: python discord

我正在制作一个python机器人程序,当有人键入[react时,该机器人程序将以()或Unicode(U + 1F611)进行响应

我目前有以下代码:

async def on_message(message):
if message.content.startswith('[react'):
  author=message.author
  discord.Client.add_reaction(author,'U+1F611')

当我尝试这种情况并键入[react,我会收到此错误:

Ignoring exception in on_message
Traceback (most recent call last):
 File "/home/runner/.site-packages/discord/client.py", line 307, in 
_run_event
yield from getattr(self, event)(*args, **kwargs)
File "main.py", line 21, in on_message
discord.Client.add_reaction(author,'U+1F611')
TypeError: add_reaction() missing 1 required positional argument: 'emoji

如果有人知道出了什么问题,我将非常感激。

1 个答案:

答案 0 :(得分:0)

由于某种原因,无法选择@sehigle作为答案,但帖子:

Have you tried '\U0001F611' ? Aren't you missing 'await'? 

https://www.reddit.com/r/discordapp/comments/8j1ywl/discordpy_how_to_use_add_reaction/

他解决了这个问题,非常感谢!