问题
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:
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)
来源:https://stackoverflow.com/questions/53357677/discord-py-reaction-bot-that-gives-a-role