[英]Discord.py | How to make a discord bot that gives roles when i send a specific message?
I tried this:我试过这个:
@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)
but im getting this error:但我收到这个错误:
discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role
i swear i typed the name of the role correctly我发誓我正确输入了角色名称
According to the docs, member.add_roles
doesn't need the message.author
argument.根据文档, member.add_roles
不需要message.author
参数。 If you remove that it should work fine.如果你删除它应该可以正常工作。
await message.author.add_roles(role)
https://discordpy.readthedocs.io/en/master/api.html?highlight=add_roles#discord.Member.add_roles https://discordpy.readthedocs.io/en/master/api.html?highlight=add_roles#discord.Member.add_roles
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.