Skip to content

Commit

Permalink
fix: select menu specs (#563)
Browse files Browse the repository at this point in the history
* fix: select menu specs

* fix: spec for mentionable select

* test: add dynamic select menu
  • Loading branch information
wolffparkinson authored Jan 6, 2023
1 parent 739979f commit 769f08b
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion test/message-components.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class MessageComponentsSpec {
public onMentionableSelect(
@Context() [interaction]: MentionableSelectContext,
@SelectedUsers() users: ISelectedUsers,
@SelectedUsers() members: ISelectedMembers,
@SelectedMembers() members: ISelectedMembers,
@SelectedRoles() roles: ISelectedRoles
) {
return interaction.reply({
Expand All @@ -250,6 +250,43 @@ export class MessageComponentsSpec {
`
});
}

@SlashCommand({
name: 'dynamic-select/:id',
description: 'Creates a dynamic string select component.'
})
public async createDynamicStringSelect(@Context() [interaction]: SlashCommandContext) {
return interaction.reply({
content: `Dynamic String Select Menu`,
components: [
new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents([
new StringSelectMenuBuilder()
.setCustomId('preferences/color')
.setPlaceholder('Select a color')
.setMaxValues(1)
.setMinValues(1)
.setOptions([
{ label: 'Red', value: 'Red' },
{ label: 'Blue', value: 'Blue' },
{ label: 'Yellow', value: 'Yellow' }
])
])
]
});
}

@StringSelect('preferences/:item')
public onPreferenceSelect(
@Context() [interaction]: StringSelectContext,
@SelectedStrings() values: string[],
@ComponentParam('item') item: string
) {
return interaction.reply({
content: `
${item} = ${values.join(',')}\n
`
});
}
}

createApplication(MessageComponentsSpec);

0 comments on commit 769f08b

Please sign in to comment.