Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bug related to an add role command on discord.py

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)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading