#SelectMenu and SelectOptions

1 messages · Page 1 of 1 (latest)

round turret
#

I am update from v4 to v5 and my Code is not working.
I read the Docs and i found no Solution.

My Code:

@i.slash_command(name='server', description='Server Administration')
async def server(ctx: i.SlashContext):

    msg = iSM(iSO(label='📰| Nachrichten', value='Nachrichten'),
              iSO(label='Test', value='Test'),
              custom_id='server_msg', min_values=1, max_values=1)

    await ctx.send('**Wähle eine Option aus!**', components=msg)

@i.component_callback('server_msg')
async def my_callback(ctx: i.ComponentContext, options: list[str]):

    option = options[0]

    if option == 'Nachrichten':

        await ctx.send('Danke das du dich dafür entschieden hast!', ephemeral=True)
        await ctx.member.add_role(role=role)




TypeError: my_callback() missing 1 required positional argument: 'options'
formal mountainBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

verbal chasm
#

now the options are put in ctx.values

round turret
#

You did not mean that right?

@i.component_callback('server_msg')
async def my_callback(ctx: i.ComponentContext):

    if ctx.values == 'Nachrichten':
verbal chasm
#

ctx.values is the same as options in v4

round turret
#

But when i do this, then it is still not working.
I think i misunderstand something

@i.component_callback('server_msg')
async def my_callback(ctx: i.ComponentContext, values: list[str]):

    value = values[0]

    if value == 'Nachrichten':



TypeError: my_callback() missing 1 required positional argument: 'values'
clear ravine
#
@i.component_callback('server_msg')
async def my_callback(ctx: i.ComponentContext):
   values = ctx. values
    value = values[0]

    if value == 'Nachrichten':




round turret
#

Now it is working, thank you very much

#

👍