Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何为我刚刚发送的消息添加反应_Python_Python 3.x_Discord_Discord.py Rewrite - Fatal编程技术网

Python 如何为我刚刚发送的消息添加反应

Python 如何为我刚刚发送的消息添加反应,python,python-3.x,discord,discord.py-rewrite,Python,Python 3.x,Discord,Discord.py Rewrite,我的一个Cog文件中有一个任务函数,如下所示。它不是命令,只是每30秒作为后台任务运行一次。我想对我刚刚发送的消息添加一个反应。我该怎么做 async def _say_hello(self, channelId): channel = self.client.get_channel(channelId) await channel.send("Hi everyone") await channel.add_reaction(':heart:') # This part

我的一个Cog文件中有一个任务函数,如下所示。它不是命令,只是每30秒作为后台任务运行一次。我想对我刚刚发送的消息添加一个反应。我该怎么做

async def _say_hello(self, channelId):
    channel = self.client.get_channel(channelId)
    await channel.send("Hi everyone")
    await channel.add_reaction(':heart:') # This part gives me an error

发送消息时,您可以将其插入变量并将其用作对象,如下所示:

async def\u说你好(self,channelId):
channel=self.client.get\u通道(channelId)
msg=等待频道发送(“大家好”)
等待消息。添加\u反应('❤') # 心脏的unicode是\u2764
添加反应时,您希望使用实际的表情符号(如果您的编辑器支持),或unicode,您可以从网站上获得

自定义表情符号
async def\u说你好(self,channelId):
channel=self.client.get\u通道(channelId)
msg=等待频道发送(“大家好”)
emoji=discord.utils.get(ctx.guild.emojis,name=“emojiname”)
#emoji=discord.utils.get(ctx.guild.emojis,id=11223344566778899)替代方法
等待消息添加反应(表情符号)
discord.utils: obj=discord.utils.get(iter,attr=“something”) #例子 member=discord.utils.get(ctx.guild.members,id=11223344566778899) channel=discord.utils.get(ctx.guild.text\u channels,name=“general”)
查找特定对象时,可以使用该对象具有的任何属性。如果需要任何提示,请参阅。

出于某种原因,它会告诉我
discord.errors.HTTPException:400错误请求(错误代码:10014):Unknown Emoji
。有没有办法将Emoji硬编码为字符串,而不是获取然后让bot去获取Emojiobject@ZoeyMalkov抱歉忘记了表情符号部分!相应地编辑了我的答案:)@ZoeyMalkov还添加了自定义表情符号功能。