为用户分配角色

时间:2020-05-09 12:45:14

标签: python-3.x discord discord.py-rewrite

我试图让我的机器人通过反应来为用户分配角色,但是为了使其能够正常工作,我在测试命令中编写了代码以首先确保其正常工作。这是我想出的:

@client.command(pass_context=True) 
async def Role(ctx):
    user = ctx.author #get user object from context
    role = get(user.guild.roles, name="testrole") #get role object by name from the get function from discord utils.
    await client.add_roles(user, role) #assign role using the add_roles coroutine by using the user and role variables as arguments

控制台输出:

AttributeError:'Bot'对象没有属性'add_roles'

我得到的意思是客户端“机器人”不了解什么是add_roles,我是否缺少某种引用或参数?

0 个答案:

没有答案