Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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


@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')

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading