discord - 如何对特定消息使用react (discord.py)

标签 discord discord.py

我正在编写一个建议机器人,它应该将玩家的建议发送到我服务器中的建议 channel ,并在建议 channel 中用一些表情符号使用react。

问题是使用“消息”作为消息参数会对发送到触发代码的消息使用react,但我希望它对机器人发送到建议 channel 的消息使用react。我对编码相当陌生。如何让机器人对不同 channel 中的消息使用react?

text_channel = client.get_channel('527127778982625291')
msg = 'Your suggestion has been sent to '+str(text_channel.mention)+' to be voted on!'
await client.send_message(message.channel, msg)
msg = str(message.author.mention)+' suggested "'+str(repAdder)+'"'
await client.send_message(discord.Object(id='527127778982625291'), msg)
print(message)
await client.add_reaction(bot_message, ":yes:527184699098136577")
await client.add_reaction(bot_message, ":no:527184806929235999")
await client.add_reaction(bot_message, '🤷')

最佳答案

您需要将 react 添加到机器人发送的消息中,而不是用户发送的消息中。
将 bot-sent-message 作为 Message 对象传递给 client.add_reaction() 而不是原始消息应该可以解决问题。

关于discord - 如何对特定消息使用react (discord.py),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53926093/

相关文章:

javascript - 如何为我的机器人编写带有推理功能的踢球

javascript - 缩短公会角色列表

discord - 在 Discord.py 中获取用户总邀请

python - 如何在discord.py重写上获取用户角色

python-3.x - Selenium 和异步

python - 我制作了一个获取股票价格的 python 机器人,但我该怎么做才能使参数不使用空格?

python - 使用 Discord.py 制作一个在预定日期发送消息的机器人

python - 显示角色成员discord.py

python - 如何使 discord.py bot 成为非作者的私有(private)/直接消息?

python - Discord.py - 自动更改角色颜色