【问题标题】:How do you add roles in discord.py?如何在 discord.py 中添加角色?
【发布时间】:2019-07-04 22:41:09
【问题描述】:

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

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(无成员)

【问题讨论】:

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-09-21
    • 2018-06-21
    • 2021-07-26
    • 2021-03-26
    • 2021-07-06
    • 2021-07-20
    • 2021-03-16
    • 2021-06-05
    • 2019-08-11
    相关资源
    最近更新 更多