机器人应在加入时将用户添加到“示例角色”,但请给我一个错误,请帮助。
我的代码:
@client.event
async def on_member_join(member):
role = discord.utils.get(member.server.roles, name='Example Role')
await client.add_roles(member,role)
错误:
> Ignoring exception in on_member_join Traceback (most recent call
> last): File
> "C:\Users\Ethan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py",
> line 307, in _run_event yield from getattr(self, event)(*args,
> **kwargs) File "C:\Users\Ethan\Desktop\Eco bot.py", line 27, in on_member_join await client.add_roles(member,role) File
> "C:\Users\Ethan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py",
> line 2905, in add_roles yield from self._replace_roles(member,
> new_roles) File
> "C:\Users\Ethan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py",
> line 2876, in _replace_roles yield from
> self.http.replace_roles(member.id, member.server.id, roles) File
> "C:\Users\Ethan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\http.py",
> line 133, in request raise Forbidden(r, data)
> discord.errors.Forbidden: FORBIDDEN (status code: 403): Missing
> Permissions
答案 0 :(得分:0)
该机器人没有manage_roles权限,因此我将该机器人移到了列表的顶部,因此它可以编辑下面的任何人。谢谢。
答案 1 :(得分:0)
授予bot的Manage_roles权限,并注意当其在层次结构中处于较高位置时,该bot不能更改用户。