M
M
minomo2020-10-03 15:21:53
Python
minomo, 2020-10-03 15:21:53

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_tempThrows 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.

What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-10-03
@minomo

mnJQqq3.png"UMVR"
Make sure the role with ID 724322899921600513exists, 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 question

Ask a Question

731 491 924 answers to any question