Python Discord BOT. Simple, but annoying error

时间:2017-06-15 09:29:21

标签: python discord discord.py

I just discovered this site, and I wondered if someone could help me. I don't really know if this title is appropriate, but that'll do for the moment.

So, I've got a code that looks like this :

@client.command(pass_context=True)
async def member(self, *, member: discord.Member = None, role : discord.Role = None):
    if member is None:
        await client.say("You need to tag someone!")
    elif role is None:
        await client.say("You need to tag a role to add!")
    else:
        await client.add_roles(member, role)
        await client.say("Role added!")

I think it's "working" quite well, because I do not see any errors when typing the !member @Dude command. The BOT just tells me that I need to tag a role to add. BUT! When I tag a role to add, then it doesn't work. In fact, the problem is, the BOT thinks that the role I tag is part of the name of the member. Maybe it will be better with the error. The error I told you about is one the last line of this image.

As you can see, it says that the member wasn't found. But the second ID is supposed to be the role's one. What am I doing wrong? I'm really bad with discord.py so if someone could help me, it would be very nice of him! :)

(Also, sorry for my bad english and sorry if this is off-topic, it's just that I'm fed up with these errors, because I always get another when one is solved.)

EDIT : I just fixed this, but now I get the a perms error. "Forbidden: FORBIDDEN (status code: 403) : Missing Permissions"

2 个答案:

答案 0 :(得分:1)

确保您已获得机器人管理角色权限。如果没有,则无法添加或删除角色。还要确保角色层次结构中的机器人比要添加它的角色更高。

答案 1 :(得分:0)

  

我刚修好了,但现在我得到了一个perms错误。 "禁止:禁止(状态代码:403):遗漏权限"

Bot必须在服务器上拥有Manage Roles权限,并且要添加的角色必须低于机器人的首要角色