Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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, '🤷')
like image 626
Eddy Zhao Avatar asked Oct 16 '22 09:10

Eddy Zhao


1 Answers

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.

like image 194
Lorddirt Avatar answered Dec 26 '22 22:12

Lorddirt