2
votes

How do I make a bot that would give people roles when they reacted to a specific thing? So far I have this but it does not work

@client.event
async def on_ready():
    channel = client.get_channel('513546504481406979')
    role = discord.utils.get(user.server.roles, name="testrole")
    message = await bot.send_message(channel, "React to me!")
    while True:
        reaction = await bot.wait_for_reaction(emoji="????", message=message)
        await bot.add_roles(reaction.message.author, role)
1

1 Answers

1
votes

wait_for_reaction returns a (reaction, user) tuple. You only need the user portion to assign the role:

reaction, reactor = await bot.wait_for_reaction(emoji="👍", message=message)
await bot.add_roles(reactor, role)