首页 > 解决方案 > 如何在 discord.py 中添加角色?

问题描述

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

client.add_roles(member, role)

我已经尝试了所有我能想到的代码,它只是给了我这个信息,我已经查看了其他几个问题来寻找答案,但每个人都说要执行我尝试过的那个命令,但它不会工作。

@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(no-member)

标签: pythonpython-3.xdiscord.pydiscord.py-rewrite

解决方案


await gmember.add_roles(role)你可以在这里 阅读更多


推荐阅读