您如何在discord.py中添加角色?

时间:2019-07-04 04:24:18

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

我正在尝试为某人添加角色,但是当我这样做

client.add_roles(member, role)

我已经尝试了所有我能想到的代码所提供的信息,我在寻找答案的过程中查看了其他几个问题,但是每个人都说要执行我尝试过的该命令,但是它不会起作用。 / p>

@client.command(pass_context=True)
@commands.has_role('Unverified')
async def verify(ctx, nickname):
    gmember = ctx.message.author #This is the looking for the memeber
    role = discord.utils.get(gmember.server.roles, name='Guild Member')
    channel = client.get_channel(401160140864094209)
    await gmember.edit(nick=f"{nickname}")
    await ctx.channel.purge(limit=1)
    r = requests.get("This is the link to the API but it shows my key and everything so not going to put it here but it works in other commands")
    #if nickname in role:
    #  await ctx.send(f"You have already verified your account.")
    if nickname.encode() in r.content:
        await channel.send(f'@here ``{nickname}`` is in the guild.')
        await client.add_roles(gmember, role)
    else:
        await gmember.kick()

Bot的实例没有add_roles成员pylint(无成员)

1 个答案:

答案 0 :(得分:0)

await gmember.add_roles(role) 您可以阅读更多here