How to react to a specific message (discord.py)

纵饮孤独 提交于 2021-01-27 07:40:48

问题


I'm coding a suggestion bot that's supposed to send a player's suggestion to a suggestions channel in my server and react in the suggestions channel with some emojis.

The problem is that using 'message' as the Message parameter would react to the message sent to trigger the code, but I want it to react to the message the bot sent to the suggestions channel. I'm fairly new to coding. How can I get the bot to react to a message in a different channel?

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, '🤷')

回答1:


You needed to add the reaction to the message that the bot sent, not the user-sent message. Passing the bot-sent-message as a Message object to client.add_reaction() instead of the original message should fix the problem.



来源:https://stackoverflow.com/questions/53926093/how-to-react-to-a-specific-message-discord-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!