Bug related to an add role command on discord.py

Question:

I have this command I made with a Discord bot in Python. Basically, it’s an event where it gives you a "Saloon Member" role when you write "givemembership" this command has been working on some of my test servers but sometimes simply didn’t.(I always gave the bot the admin perms.)When it didn’t work, the logs of the bot were saying the following :
enter image description here
Could someone maybe explain to me why it is not working ?
Here’s the command programm.

@bot.event
async def on_message(message):
    if message.content == "givemembership":
        member = message.author
        role = get(member.guild.roles, name="Saloon Member")
        await member.add_roles(role)
Asked By: Soren Forgeman

||

Answers:

The Forbidden error implies the bot doesn’t have permissions – so I would make sure that the bot’s role (or a role that the bot has) is always above the role you want it to be able to assign. Otherwise it won’t have the necessary perms.

Answered By: ESloman
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.