Discord.py反应机器人,它提供了一个角色 [英] Discord.py Reaction bot that gives a role

查看:20
本文介绍了Discord.py反应机器人,它提供了一个角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何制作一个机器人,当人们对一件特定的事情做出反应时,它会为他们提供角色?到目前为止,我有这个,但它不起作用

@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)

推荐答案

wait_for_reaction返回(reaction, user)元组。您只需要user部分即可分配角色:

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

这篇关于Discord.py反应机器人,它提供了一个角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆