如何在discord.py 0.16.12中向用户添加角色?

时间:2018-12-01 21:06:14

标签: discord.py

如何为具有discord.py的人添加角色?我遵循了api,但是它不起作用,并说我遇到语法错误。

这是我的代码:

member = message.author
role = discord.utils.get(message.author.server.roles, name="game1")
await client.add_roles(member, role)

1 个答案:

答案 0 :(得分:-1)

from discord.ext import commands

@bot.command(pass_context=True)
async def role(ctx):
    member = ctx.message.author
    role = get(member.server.roles, name="game1")
    await bot.add_roles(member, role)