Home > OS >  Hello, im trying to create a discord-music-bot, and have an error like: "This interaction faile
Hello, im trying to create a discord-music-bot, and have an error like: "This interaction faile

Time:12-02

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='$')


@bot.command()
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'),
                   components=[
                    [
                       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 ?'),
                components=[
                [
                    Button(style=ButtonStyle.red, label='No'),
                    Button(style=ButtonStyle.URL, label='Yep', url='https://www.youtube.com/')
                ]
            ]
            )

bot.run('TOKEN')

CodePudding user response:

Try to add the following to initialize discord_components module:

@bot.event
async def on_ready():
    DiscordComponents(bot)

Also import DiscordComponents instead of Discord_Components.

  • Related