5
votes

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
If I understand this right, it's reacting to the message the player sent instead of the one the bot is sending in #suggestions right? You should get the message the the bot sent in #suggestions and use add_reaction(bot_message, "") instead of reaction to 'message', which is the message the player sent. - Lorddirt
I just tried replacing "message" with "bot_message" but now i have an error: NameError: name 'bot_message' is not defined - Eddy Zhao
I was just using the variable bot_message as an example lol, In your code, you have "await client.send_message(message.channel, msg)". That's the message the bot is sending right? Get that message as a variable and it should work. - Lorddirt
I did it, and it worked! Thanks so much for your help! - Eddy Zhao

1 Answers

3
votes

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.