I am using a library called discord-py-slash-command to implement slash commands and dropdown menus into my discord bot, coded in discord.py.
My problem is that I am unable to assign custom IDs to different items, and therefore I cannot identify the selected item. Using a separate bot event will not work for me.
I have successfully created a basic dropdown menu with the following code:
select = create_select(
options=[
create_select_option("Option 1", value="Option 1", emoji="1️⃣"),
create_select_option("Option 2", value="Option 2", emoji="2️⃣"),
create_select_option("Option 3", value="Option 3", emoji="3️⃣"),
],
placeholder="Choose an option or two",
min_values=1,
max_values=2,
)
await user.send("Select options here", components=[create_actionrow(select)])
I then use the following code to wait for selected items and then send the results:
select_ctx: ComponentContext = await wait_for_component(client, components=create_actionrow(select))
await select_ctx.edit_origin(content=f"You chose an option!")
I would like to be able to assign a custom ID to each select option in the top code block because the random IDs generated for you are very long and unmemorable, such as:
7816e661-7751-4e1b-8ab0-24b00a0537cc
I've tried adding both custom_id
and id
parameters to each select option in select
. When I do so, I receive the following error:
TypeError: create_select_option() got an unexpected keyword argument 'custom_id'
Is assigning custom IDs only available for buttons or am I assigning the ID in the wrong place? I'd appreciate any answers or feedback. Thanks!
There is a custom_id
for dropdowns. You place it exactly after the min
and max
values.
Select = create_select(options = [
create_select_option("Option 1", value="Option 1", emoji="1️⃣"),
create_select_option("Option 1", value="Option 1", emoji="1️⃣"),
create_select_option("Option 1", value="Option 1", emoji="1️⃣"),
],
placeholder="Choose a help category",
min_values=1,
max_values=1,
custom_id="helpuwu",
)