Skip to content

select

select<T, O>(type, config, run): Select<T, [O] extends [never] ? SelectValue[T] : O[keyof O]>

Defined in: select.ts:42

Declares a select menu and the handler that runs when the user picks from it. Put it in the selects of a message, such as c.reply('Pick one', { selects: [menu] }), and in the selects of bot so the bot gets the pick. Each menu takes a row of its own, above the buttons.

A string menu lists options, keyed by the label Discord shows, and the handler gets the picked values. A user, role, channel or mentionable menu lets the user pick from the server, and the handler gets the full objects Discord resolved. A channel menu takes channelTypes.

T extends SelectType

O extends Record<string, T extends "string" ? string : never> = never

T

What the user picks from.

SelectConfig<T, O>

How Discord shows the menu.

(c) => Response | Promise<Response>

Answers the pick. c.values holds the picked items.

Select<T, [O] extends [never] ? SelectValue[T] : O[keyof O]>

The select menu.

const fruit = select('string', { id: 'fruit', options: { Apple: 'apple', Mango: 'mango' } }, (c) =>
c.update(`picked ${c.values.join(', ')}`),
);