Theodore
Theodore

Reputation: 1

Python Discord BOT. Simple, but annoying error

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"

Upvotes: 0

Views: 6395

Answers (2)

Fixator10
Fixator10

Reputation: 670

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

Bot must have Manage Roles permission on server, and role to add must be lower then bot's top role

Upvotes: 1

Tim
Tim

Reputation: 1173

Make sure that you have given the bot manage role permissions. If it doesn't have that then it can't add or remove roles. Also make sure that the bot is higher in the role hierarchy than the role you are getting it to add.

Upvotes: 5

Related Questions