#Append Option in Menu

1 messages · Page 1 of 1 (latest)

civic depot
#
@bot.command()
async def rick(ctx):
    select = Select(
        min_values=1,
        max_values=2,
        placeholder="Choose Someone",
        options=[discord.SelectOption(
            label="Auschwitz",
            description="ça gaze ?"
        ),
            discord.SelectOption(
                label="Birkenau",
                description="c'est chaud !",
                emoji=":Tim_Coins_Fast:"),

        ],
    )

    async def select_callback(interaction):
        if len(select.values) == 2:
            await interaction.response.send_message("Nope")
        elif select.values[0] == 'Auschwitz':
            select.append_option(discord.SelectOption(label="Hey"))
            await interaction.response.send_message("L'état gazeux")
            select.append_option(discord.SelectOption(label="Test Append")) #the line who dosen't work
        elif select.values[0] == 'Birkenau':
            await interaction.response.send_message("Une Gare De Pétrole (apparemment...)")
        else:
            await interaction.response.send_message("Error")

    select.callback = select_callback
    view = View()
    view.add_item(select)
    await ctx.send("Rick Rolled !", view=view)

The Menu doesn't append the option

inland oasis
civic depot
#

a command : update (or same like this) ?

inland oasis
#

editing the message

#

e.g. await self.message.edit(view=self)

#

wait no

#

you need to reorder how you've defined everything

civic depot
#

/@civic depot >> wait

inland oasis
#

define view above the callback

#

then inside the callback, you could do either await interaction.message.edit(view=view) or await view.message.edit(view=view), one of the two should work

civic depot
#

Okay i have few difficulties to understand quickly (i'm french sorry)
So you would like i do :

@bot.command()
async def rick(ctx):
    select = Select(
        min_values=1,
        max_values=2,
        placeholder="Choose Someone",
        options=[discord.SelectOption(
            label="Auschwitz",
            description="ça gaze ?"
        ),
            discord.SelectOption(
                label="Birkenau",
                description="c'est chaud !",
                emoji=":Tim_Coins_Fast:"),

        ],
    )

view = View()

    async def select_callback(interaction):
        if len(select.values) == 2:
            await interaction.response.send_message("Nope")
        elif select.values[0] == 'Auschwitz':
            select.append_option(discord.SelectOption(label="Hey"))
            await interaction.response.send_message("L'état gazeux")
            await interaction.message.edit(view=view)
        elif select.values[0] == 'Birkenau':
            await interaction.response.send_message("Une Gare De Pétrole (apparemment...)")
        else:
            await interaction.response.send_message("Error")

    select.callback = select_callback
    view.add_item(select)
    await ctx.send("Rick Rolled !", view=view)

Like That's ?

floral flower
#

oh yeah if you want to use view.message

#

anyway defining the callback like this is not the greatest of ways of doing it

#

you could subclass ui.Select which would make it a lot easier

civic depot
#

Yeah i know you can define a class Select and do many things

floral flower
#

also in your code you haven't edited the message to update the view

#

as nelo said before

#

well actually you do but only if the user selects "auschwitz"

civic depot
#

But currently i test, many things

For the BOT n°2 why not...

civic depot
floral flower
#

just put it at the bottom

civic depot
#

Yeah it's just a Crash Test Function, so she will be disappear...