Answer the question
In order to leave comments, you need to log in
Coroutine not working from .add_roles() method in discord.py?
@client.command()
async def test_get_role(ctx, member: discord.Member = None):
# Получить роль
role = discord.utils.get(ctx.guild.roles, id = 724322899921600513)
cr_temp = ctx.author.add_roles(role)
print(cr_temp) # <coroutine object Member.add_roles at 0x00000000>
await cr_temp # Выбрасывает из функции
await ctx.message.add_reaction('✅')
await cr_temp
Throws out of the function
after the line . In all places in the code, the coroutine returned from .add_roles() simply breaks execution when it starts. Answer the question
In order to leave comments, you need to log in
"UMVR"
Make sure the role with ID 724322899921600513
exists, for example by adding print(role)
Tip: Use guild.get_role(ID)
instead of discord.utils.get
, it reads better
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question