discord .py |如何使一个不和谐的机器人,给角色,当我发送一个特定的消息?



我试过了:

@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

相关内容

最新更新