I want that the bot to give a role to the person who reacted to the message. The bot should also dm the person who had reacted. Thank you in advance.
This is my code:
@client.event
async def on_raw_reaction_add(payload):
if payload.emoji.name == "💜" and payload.user_id != client.user.id:
embed = discord.Embed(
description = "**You are now a Member of Resellheads!** ",
color=16769251)
channel = client.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
await message.channel.send(embed=embed)
await message.channel.send("<@&776929011757613057> Please add the role 'Member'!")
There's no need to use raw reaction add in your case, as you are only using it to send a command.
@client.event
async def on_reaction_add(reaction, user):
if reaction.emoji == '💜':
await user.send("You are now a member of your community!")
if reaction.emoji == '💔':
await user.send("Sad to see you leave")
This will simply send any user who reacts with a thumbs up or down your command/message.
In this case, if your bot is a private or small bot this should be fine to use, but getting larger and in more servers, you should use a reaction wait that waits for he specified reaction after the author sent the command. There wasn't much detail explained in your question but I hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.