T
T
Telmor2021-11-09 23:56:57
Python
Telmor, 2021-11-09 23:56:57

How to remove role from server in discord.py?

I want to remove user role on button click. Everything works fine for me, I get the role through id with

roles = discord.utils.get(ctx.author.guild.roles, id=role)

But when I want to delete the role, errors occur.
My code:
await self.bot.delete_role(roles)
Then the error is written:
Command raised an exception: AttributeError: 'Bot' object has no attribute 'delete_role'

I ask to prompt as it is possible to delete a role from the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Telmor, 2021-11-10
@Telmor

I found the answer. Decision:
await roles.delete()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question