我试过了:
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == 'give me admin':
role = get(message.guild.roles, name='role')
await message.author.add_roles(message.author, role)
但是我得到这个错误:
discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role
我发誓我输入的角色名是正确的
根据文档,member.add_roles
不需要message.author
参数。如果你删除它,它应该可以正常工作。
await message.author.add_roles(role)
https://discordpy.readthedocs.io/en/master/api.html?highlight=add_roles discord.Member.add_roles