#SelectMenu Callback Disable

1 messages · Page 1 of 1 (latest)

humble parrot
#

How can I disable a select menu after one interaction?
I tryed

@interactions.component_callback("sm")
async def callback(ctx: interactions.ComponentContext):
    ctx.component.disabled = True
    [...]

but it doesn't work.

stuck shoalBOT
#

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

humble parrot
#

Is there a helpful page in the docs? I only found the callbacks for buttons, but not for SelectMenus

rain owl
#

Can you show thee code you did for how you sent the select menu?

chrome olive
#

you need to edit the message and send again the disabled component

#

ctx.edit_origin(components=...)

humble parrot
# rain owl Can you show thee code you did for how you sent the select menu?
@interactions.slash_command(
    name="test"
)
async def test(ctx: interactions.SlashContext):
    comp = interactions.StringSelectMenu(
        interactions.StringSelectOption(label="1", value="1", description="...", emoji=":beers:"),
        interactions.StringSelectOption(label="2", value="2", description="???...!!!", emoji=":skull:"),
        interactions.StringSelectOption(label="3", value="3", description=",,", emoji=":800AAAA2:"),
        interactions.StringSelectOption(label="4", value="4", description="Something", emoji=":beers:"),
        custom_id="sm",
        placeholder="Choose one option",
        min_values=1,
        max_values=1
    )
    await ctx.send(components=comp)

@interactions.component_callback("sm")
async def callback(ctx: interactions.ComponentContext):
    print(ctx.values)
    ctx.component.disabled = True
    await ctx.send(f"You clicked!")
chrome olive
humble parrot