Hello, im trying to create a discord-music-bot, and have an error like: "This interaction failed" when im pressing the choose button


I’m writing the command, like $playlist, then ive a 4 variants. I want to press the button and open the link, but i’ve got this error. What am i doing incorrectly ?

import discord
from discord.ext import commands
import config
from discord_components import Discord_Components, Button, ButtonStyle

intents = discord.Intents.all()
bot = commands.Bot(command_prefix='$')

async def playlist(ctx):
    await ctx.send('Hey! You can choose the playlist by choosing your mood:')

    await ctx.send(('1. Test1\n2. Test2.\n3. Test3'\n4. Test4'),
                       Button(style=ButtonStyle.blue, label='Test1', custom_id='1'),
                       Button(style=ButtonStyle.green, label='Test2', custom_id='2'),
                       Button(style=ButtonStyle.red, label='Test3', custom_id='3'),
                       Button(style=ButtonStyle.gray, label='Test4', custom_id='4')

    response = await bot.wait_for("button_click", check=lambda inter: inter.channel == ctx.channel)
        if response.custom_id == '1':
            await response.respond(
                embed=discord.Embed(title='Open it ?'),
                    Button(style=ButtonStyle.red, label='No'),
                    Button(style=ButtonStyle.URL, label='Yep', url='https://www.youtube.com/')


>Solution :

Try to add the following to initialize discord_components module:

async def on_ready():

Also import DiscordComponents instead of Discord_Components.

Leave a ReplyCancel reply