我正在用Discord.py做一个机器人,尝试对发送的嵌入内容做出反应时出现错误,我将整个循环发布在下面,但主要错误指向行await msg.add_reaction(emoji=reactions)
。我知道unicode字符串必须在上面的函数中传递,但是即使unicode完全相同,但如果通过文本通道接收它似乎也不会接受它。我什至还添加了打印功能,以查看unicode是否打印完全相同,并且它的长度完全相同,没有空格。如果我仅将unicode作为字符串直接输入,例如:await msg.add_reaction(emoji='\U0001f310')
,则它可以工作并且能够以正确的反应对消息进行响应,但是如果我通过msg.content接收到该消息,然后将其传递给函数然后抛出未知的表情符号错误。我知道消息内容很好,因为它准确地打印到了控制台。任何帮助,将不胜感激。
这是我得到的错误:
\U0001f310
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Joe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 227, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Joe\Desktop\voicebot discord\test2.py", line 94, in on_message
await msg.add_reaction(emoji=reactions)
File "C:\Users\Joe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\message.py", line 708, in add_reaction
await self._state.http.add_reaction(self.id, self.channel.id, emoji)
File "C:\Users\Joe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 214, in request
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400): Unknown Emoji
我的代码:
while embedLoop:
await channel.send('What is the title?')
msg = await client.wait_for('message', check=check)
title = msg.content
await channel.send('The title is ' + title)
await channel.send('What is the description?')
msg = await client.wait_for('message', check=check)
desc = msg.content
await channel.send('The description is ' + desc)
await channel.send('Enter emoji unicode: ')
msg = await client.wait_for('message', check=check)
reactions = msg.content
embed=discord.Embed(colour = 4691711)
embed.add_field(name=title, value= desc, inline=False)
msg = await embedChannel.send(embed=embed)
print(reactions)
await msg.add_reaction(emoji=reactions)