SelectMenuBuilder Union Types

I'm attempting to send a SelectMenu in a message but I'm getting this error
Unhandled promise rejection: Invalid Form Body\ndata.components[0].components[0][UNION_TYPE_CHOICES]: Value of field \"type\" must be one of (2, 3, 5, 6, 7, 8).\ndata.components[1].components[0][UNION_TYPE_CHOICES]: Value of field \"type\" must be one of (2, 3, 5, 6, 7, 8).
Unhandled promise rejection: Invalid Form Body\ndata.components[0].components[0][UNION_TYPE_CHOICES]: Value of field \"type\" must be one of (2, 3, 5, 6, 7, 8).\ndata.components[1].components[0][UNION_TYPE_CHOICES]: Value of field \"type\" must be one of (2, 3, 5, 6, 7, 8).
My code is in the attachment When I remove the SelectMenus, it works fine
10 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
sproj003 ♿
sproj003 ♿7mo ago
Error stack is {"code":50035,"level":"error","message":"Unhandled promise rejection: Invalid Form Body\ndata.components[0].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).\ndata.components[1].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).","method":"POST","rawError":{"code":50035,"errors":{"data":{"components":{"0":{"components":{"0":{"_errors":[{"code":"UNION_TYPE_CHOICES","message":"Value of field "type" must be one of (2, 3, 5, 6, 7, 8)."}]}}},"1":{"components":{"0":{"_errors":[{"code":"UNION_TYPE_CHOICES","message":"Value of field "type" must be one of (2, 3, 5, 6, 7, 8)."}]}}}}}},"message":"Invalid Form Body"},"requestBody":{"files":[],"json":{"data":{"allowed_mentions":{"parse":["users","roles","everyone"]},"components":[{"components":[{"custom_id":"feedback_request_modal_title","label":"Title","max_length":200,"min_length":1,"required":true,"style":1,"type":4}],"type":1},{"components":[{"custom_id":"feedback_request_modal_pages","label":"Page Count","max_length":3,"min_length":1,"required":true,"style":1,"type":4}],"type":1},{"components":[{"custom_id":"feedback_request_modal_genre","max_values":4,"min_values":1,"options":[{"description":"Action","label":"Action","value":"action"},{"description":"Adventure","label":"Adventure","value":"adventure"},{"description":"Comedy","label":"Comedy","value":"comedy"},{"description":"Crime","label":"Crime","value":"crime"},{"description":"Drama","label":"Drama","value":"drama"},{"description":"Fantasy","label":"Fantasy","value":"fantasy"},{"description":"Historical","label":"Historical","value":"historical"},{"description":"Horror","label":"Horror","value":"horror"},{"description":"Mystery","label":"Mystery","value":"mystery"},{"description":"Philosophical","label":"Philosophical","value":"philosophical"},{"description":"Political","label":"Political","value":"political"},{"description":"Romance","label":"Romance","value":"romance"},{"description":"Saga","label":"Saga","value":"saga"},{"description":"Satire","label":"Satire","value":"satire"},{"description":"Science Fiction","label":"Science Fiction","value":"science_fiction"},{"description":"Slice of Life","label":"Slice of Life","value":"slice_of_life"},{"description":"Speculative","label":"Speculative","value":"speculative"},{"description":"Thriller","label":"Thriller","value":"thriller"},{"description":"Urban","label":"Urban","value":"urban"},{"description":"Western","label":"Western","value":"western"}],"placeholder":"Select genre(s)","type":3}],"type":1}],"content":"Please fill out the form below","flags":64,"tts":false},"type":4}},"stack":"DiscordAPIError[50035]: Invalid Form Body\ndata.components[0].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).\ndata.components[1].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).\n at handleErrors (C:\Users\joels\OneDrive\Blazing Bots\SkillCamp\node_modules\@discordjs\rest\dist\index.js:687:13)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async BurstHandler.runRequest (C:\Users\joels\OneDrive\Blazing Bots\SkillCamp\node_modules\@discordjs\rest\dist\index.js:786:23)\n at async _REST.request (C:\Users\joels\OneDrive\Blazing Bots\SkillCamp\node_modules\@discordjs\rest\dist\index.js:1218:22)\n at async ButtonInteraction.reply (C:\Users\joels\OneDrive\Blazing Bots\SkillCamp\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)","status":400,"timestamp":"2023-11-08 03:24:46","url":"https://discord.com/api/v10/interactions/1171651505179328563/aW50ZXJhY3Rpb246MTE3MTY1MTUwNTE3OTMyODU2MzpJSUFzd1kzcjFaTVUwWXZJTFdqd3ZxSnh0T3VwZFBWTksyS1k4Y093OHFNaGVvYVhFQzR6ekpmQ2ViUldNNXppUmlqZ2pjbXBMVDJCVHFQaDlwSlJUVTlhT3dlUTdBMW4xOVk0TVBJa1FqQ3NzQ2FMYWlMZ3R3bURQM0ttRE9VWg/callback"}
Danial
Danial7mo ago
How do you define modal?
sproj003 ♿
sproj003 ♿7mo ago
I removed that line because it wouldn't work either, had the same error It should just be sending the Action Rows in a message now
duck
duck7mo ago
text inputs can only be used in modals they cannot be sent in messages
sproj003 ♿
sproj003 ♿7mo ago
Is it true that Select Menus can't be used in modals?
Danial
Danial7mo ago
Yes, only text inputs
sproj003 ♿
sproj003 ♿7mo ago
So I have to use both messages and modals for one single form???
treble/luna
treble/luna7mo ago
messages cannot show modals Only interactions can
sproj003 ♿
sproj003 ♿7mo ago
That's what I meant