#Select menu callback trying to access user's selections before they have a chance to select any

1 messages · Page 1 of 1 (latest)

wanton quartz
#

i'm trying to get this code (see below) to make a dropdown menu for users

@bot.slash_command(description='Change your levelling color scheme!')
async def levellingcolor(intr):
    select = Select(placeholder='Choose a color scheme!',
        min_values=1,
        max_values=1,
        options=[
        discord.SelectOption(label="stuff"),
        discord.SelectOption(label="other stuff"),
        discord.SelectOption(label="etc")
    ])

    view = View()
    select.callback = await setColorScheme(intr, select)
    view.add_item(select)
    #other code
    await intr.response.send_message('Choose a color set!', view=view)```
here's the 'setColorScheme' function if needed
```python
async def setColorScheme(intr, select):
    async with aiosqlite.connect('main.db') as db:
        async with db.cursor() as cursor:
            scheme = select.values[0]
            await cursor.execute(f"UPDATE users SET colorScheme = ? WHERE id = ? AND guild = ?", (scheme, intr.author.id, intr.guild.id))
            db.commit()```

when i use `/levellingcolor` it instantly throws the following before the message is sent
```File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 980, in _invoke
    await self.callback(ctx, **kwargs)
  File "c:\Users\me\OneDrive\Documents\bot\main.py", line 326, in levellingcolor
    select.callback = await setColorScheme(intr, select)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\me\OneDrive\Documents\bot\main.py", line 308, in setColorScheme
    scheme = select.values[0]
             ~~~~~~~~~~~~~^^^```

***how can i call the `setColorScheme` only after the user has made a selection?***
open furnace
#

do it like my_select.callback = my_func

#

notice how there is no await or () around it

wanton quartz