#Application Command raised an exception TypeError Select.__init__() missing 1 required positional

1 messages · Page 1 of 1 (latest)

dry sparrow
#

a select menu is supposed to get summoned but somehow the code is throwing this error

from turtle import title
import discord
from discord.ext import commands

class Select(commands.Cog): 

    def __init__(self, bot): 
       self.bot = bot

    @discord.ui.select(
        placeholder = "Choose a Flavor!",
        min_values = 1,
        max_values = 1,
        options = [ 
            discord.SelectOption(
                label="Vanilla",
                description="Pick this if you like vanilla!"
            ),
            discord.SelectOption(
                label="Chocolate",
                description="Pick this if you like chocolate!"
            ),
            discord.SelectOption(
                label="Strawberry",
                description="Pick this if you like strawberry!"
            )
        ]
    )
    async def select_callback(self, select, interaction):
        await interaction.response.send_message(f"Awesome! I like {select.values[0]} too!")

    @discord.slash_command(description="summon a select menu")
    async def select(self, ctx):
        
        await ctx.respond("Choose a flavor!", view=Select())

def setup(bot): 
    bot.add_cog(Select(bot))```
iron sundial
#

call the super().__init__ in your __init__

iron sundial
dry sparrow
iron sundial
#

you cant use a select class as a cog

#

create one class as cog and one as select menu, then call the selcect menu class in your cog

dry sparrow
#

'Select' object has no attribute 'children'

iron sundial
#

show me your full code please

#

you should have something like this

class YourCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @slash_command()
    async def delete_feedbacks(self, ctx):
            view=YourSelect()

            await ctx.respond(view=view)


class YourSelect(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.select(label="")
    async def your_callback(self, button: discord.ui.select, interaction: discord.Interaction):
        ...
#

@dry sparrow

dry sparrow
#

wth
i switched the order and it worked

#

smh