question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

We cant received select menus from modal

See original GitHub issue

Which package is this bug report for?

discord.js

Issue description

I added a selectMenu component to a modal to take advantage of this new feature. However, several things: You cannot create a Modal collector, and then, second thing: when you retrieve all components (of each action_row), if the type is SELECT_MENU, the value will be undefined. However, it is sent to the Discord API when the user interacted. It is likely that it comes from an oversight on the Discord.JS library, and not from an error in the return of data.

Some codes : interactionCreate event :

interaction.fields.getField('t_selectInformationType')
/**
* Return :
* {
*    value: undefined,
*    type: 'SELECT_MENU',
*    customId: 't_selectInformationType'
* }
*/

Modal déclaration :

const modal = new Discord.Modal()
                    .setCustomId('t_modalAddInformation')
                    .setTitle("Information form");

const informationValue = new Discord.TextInputComponent()
                    .setCustomId('t_informationValue')
                    .setLabel("What's the type of the information ?")
                    .setStyle('SHORT')
                    .setMinLength(2)
                    .setMaxLength(25)
                    .setPlaceholder('Information...');

const isOptional = new Discord.MessageSelectMenu()
                    .setCustomId('t_selectInformationType')
                    .setPlaceholder("It is required ?")
                    .addOptions([
                        {
                            label: 'Yes',
                            description: 'Yes, the value is require',
                            value: 'y'
                        }, {
                            label: 'No',
                            description: 'No, it doesnt',
                            value: 'n'
                        }]);

const informationValueRow = new Discord.MessageActionRow().addComponents(informationValue);
const informationTypeRow = new Discord.MessageActionRow().addComponents(isOptional);

modal.addComponents(informationValueRow, informationTypeRow);

await interaction.showModal(modal);

Code sample

interactionCreate event :

interaction.fields.getField('t_selectInformationType')
/**
* Return :
* {
*    value: undefined,
*    type: 'SELECT_MENU',
*    customId: 't_selectInformationType'
* }
*/


Modal déclaration :
```js
const modal = new Discord.Modal()
                    .setCustomId('t_modalAddInformation')
                    .setTitle("Information form");

const informationValue = new Discord.TextInputComponent()
                    .setCustomId('t_informationValue')
                    .setLabel("What's the type of the information ?")
                    .setStyle('SHORT')
                    .setMinLength(2)
                    .setMaxLength(25)
                    .setPlaceholder('Information...');

const isOptional = new Discord.MessageSelectMenu()
                    .setCustomId('t_selectInformationType')
                    .setPlaceholder("It is required ?")
                    .addOptions([
                        {
                            label: 'Yes',
                            description: 'Yes, the value is require',
                            value: 'y'
                        }, {
                            label: 'No',
                            description: 'No, it doesnt',
                            value: 'n'
                        }]);

const informationValueRow = new Discord.MessageActionRow().addComponents(informationValue);
const informationTypeRow = new Discord.MessageActionRow().addComponents(isOptional);

modal.addComponents(informationValueRow, informationTypeRow);

await interaction.showModal(modal);


### Package version

13.7.0

### Node.js version

16.15.1

### Operating system

Linux

### Priority this issue should have

Medium (should be fixed soon)

### Which partials do you have configured?

User, Channel, GuildMember

### Which gateway intents are you subscribing to?

Guilds, GuildMembers

### I have tested this issue on a development release

_No response_

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
vladfrangucommented, Jun 17, 2022

Using third party modules not supported by us is not a good idea, especially when it comes to features Discord hasn’t even fully released yet. Patience is needed, we’ll have support for them when Discord finalises them

5reactions
almostSoujicommented, Jul 18, 2022

Select menus in modals are not yet supported. Discord.js will add full support, once discord considers the feature stable and documented (linked PR). Please do not recommend people modify the library source in local copies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot get new <select> value from dropdown in Bootstrap 4 ...
I have an image editing UI that pulls image data from a MYSQL database ... I can't seem to get the new value...
Read more >
JavaScript · Bootstrap
To take advantage of the Bootstrap grid system within a modal, ... the dropdown plugin toggles hidden content (dropdown menus) by toggling the...
Read more >
CS 204 Dropdowns, Modals and Carousels
You 'll use dropdown menus and modals in your final project. There are many solutions for these problems, including fancy transitions between slides...
Read more >
Common problems - The jQuery replacement for select boxes
Select2 does not function properly when I use it inside a Bootstrap modal. ... This issue occurs because Bootstrap modals tend to steal...
Read more >
Modals - discord.js Guide
With modals you can create pop-up forms that allow users to ... We'll cover how to create, show, and receive modal forms using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found