F
F
Forraz2022-03-16 21:09:39
Python
Forraz, 2022-03-16 21:09:39

Why does an interaction error occur on button click?

@bot.command()
async def test(ctx):
    await ctx.send(
        embed = discord.Embed(title = 'Выбери роль.', timestamp = date),
        components = [
            Button(label="Роль1", custom_id='one'),
            Button(label="Роль2", custom_id='two')
        ])
    while True:
        responce = await bot.wait_for('button_click')
        guild = bot.get_guild(responce.guild.id)
        user = responce.author
        if responce.component.id == 'one':
            role = guild.get_role(952534698754732083)
            print(role, type(role))
            await user.add_roles(role)
        elif responce.component.id == 'two':
            role = guild.get_role(953317438462763150)
            await user.add_roles(role)

The role is issued, but the error is still present.
I'm using discord-components.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question