Skip to content

Commit

Permalink
fix: don't use MessageSelectMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Feb 10, 2022
1 parent 86b6afe commit 848c1b6
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/handlers/MessageCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@ const checkValidation = async(arg: MessageArgumentTypes, content: string | Messa
if (!content) {
const text = `${user.toString()}, please define argument \`${argument.name}\`, type: ${Util.toPascalCase(ArgumentType[argument.type.toString()])}`;
if (argument.type === ArgumentType.STRING && argument.choices?.length !== 0) {
const menu = new MessageSelectMenu()
.setCustomId('argument_choices')
.setMaxValues(1)
.setMinValues(0)
.setPlaceholder('Select a choice');

menu.setOptions(
argument.choices.map(
ch => ({
label: ch.name,
value: ch.value
})
)
);

const message = await channel.send({
content: text,
components: [ new MessageActionRow().addComponents(menu) ]
components: [
{
type: 1,
components: [
{
type: 3,
customId: 'argument_choices',
minValues: 0,
maxValues: 1,
disabled: false,
options: argument.choices.map(
ch => ({
label: ch.name,
value: ch.value
})
)
}
]
}
]
});

const component: SelectMenuInteraction = await channel.awaitMessageComponent({ filter: (m) => m.componentType === 'SELECT_MENU' && m.user.id === user.id && m.channelId === channel.id && m.message.id === message.id && m.customId === 'argument_choices', time: 60000 }) as SelectMenuInteraction;
Expand Down

0 comments on commit 848c1b6

Please sign in to comment.