繁体   English   中英

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

[英]How do you add roles in 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 (无成员)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM