the new SelectMenuBuilder() - Error when adding one in my ContainerBuilder()

Hello, so I am doing my bot using the new Container and I just saw that there is a new way to create select menus. But I got an issue by creating one for the roles. I have a .json file with a few IDs and I want to add each of these IDs as options of the menu. But I got an error and I don't really know how to fix it, so I am asking here Here is my code : https://pastebin.com/0TXLxMu2 And here is the error
DiscordAPIError[50035]: Invalid Form Body
components[0].components[13].components[0].default_values[SELECT_COMPONENT_TOO_MANY_DEFAULT_VALUES]: The specified number of default values exceeds the specified maximum values
at handleErrors (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:1149:23)
at async SequentialHandler.queueRequest (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:980:14)
at async _REST.request (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:1293:22)
at async TextChannel.send (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:195:15)
at async Object.execute (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\Commands\Admin\roles.js:124:9) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: [
{
type: 17,
accent_color: 16777150,
components: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object]
]
}
],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 32768,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
components: { '0': { components: { '13': [Object] } } }
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1383081993788592169/messages'
}
DiscordAPIError[50035]: Invalid Form Body
components[0].components[13].components[0].default_values[SELECT_COMPONENT_TOO_MANY_DEFAULT_VALUES]: The specified number of default values exceeds the specified maximum values
at handleErrors (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:1149:23)
at async SequentialHandler.queueRequest (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:980:14)
at async _REST.request (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\rest\dist\index.js:1293:22)
at async TextChannel.send (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:195:15)
at async Object.execute (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\Commands\Admin\roles.js:124:9) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: [
{
type: 17,
accent_color: 16777150,
components: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object]
]
}
],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 32768,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
components: { '0': { components: { '13': [Object] } } }
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1383081993788592169/messages'
}
19 Replies
d.js toolkit
d.js toolkit6mo 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! - Marked as resolved by staff
! naaphÿ
! naaphÿOP6mo ago
Also if you could ping me when you will answer me thank you
duck
duck6mo ago
for the record, auto-populating select menus aren't really new that being said, select menus (including string select menus) default to having a max values of 1 therefore the number of default roles you've selected is over the max
! naaphÿ
! naaphÿOP6mo ago
what is the max I can put per select menus I stopped doing bot for 1 or 2 years, so didn't know before it was just a global selectMenuBuilder with .addOptions()
duck
duck6mo ago
the max you can set for the max values is 25
! naaphÿ
! naaphÿOP6mo ago
I have 18 IDs
duck
duck6mo ago
yes, but max values defaults to 1 you'll need to call .setMaxValues()
! naaphÿ
! naaphÿOP6mo ago
but that is what I want
duck
duck6mo ago
then don't select 18 roles as the default
! naaphÿ
! naaphÿOP6mo ago
oh I understand is it possible to not have all the roles by default thought it was like a filter
duck
duck6mo ago
all roles being available in the select menu is the default <RoleSelectMenuBuilder>.setDefaultroles() sets the default roles selected there is no means of filtering which roles appear in the select menu it is auto-populating
! naaphÿ
! naaphÿOP6mo ago
Ok I see I will use 18 buttons then thank you
! naaphÿ
! naaphÿOP6mo ago
@duck so I edited my code to replace the select menu with all the 18 buttons but I got an error when I responded to the interaction even though it's the same response in several of my commands. Here is the new code with all the buttons : https://pastebin.com/pzr2rQYy And the error :
return comparator(input.length, length) ? Result.ok(input) : Result.err(new ExpectedConstraintError(name, options?.message ?? "Invalid Array length", input, expected));
^

ExpectedConstraintError: Invalid Array length
at Object.run (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1045:79)
at C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
at Array.reduce (<anonymous>)
at _ArrayValidator.parse (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)
at validateComponentArray (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:1532:233)
at SectionBuilder.toJSON (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:2165:5)
at C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:1870:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:1870:35)
at C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\discord.js\src\structures\MessagePayload.js:151:46 {
constraint: 's.array(T).lengthGreaterThanOrEqual()',
given: [],
expected: 'expected.length >= 1'
}
return comparator(input.length, length) ? Result.ok(input) : Result.err(new ExpectedConstraintError(name, options?.message ?? "Invalid Array length", input, expected));
^

ExpectedConstraintError: Invalid Array length
at Object.run (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1045:79)
at C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
at Array.reduce (<anonymous>)
at _ArrayValidator.parse (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)
at validateComponentArray (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:1532:233)
at SectionBuilder.toJSON (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:2165:5)
at C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:1870:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\@discordjs\builders\dist\index.js:1870:35)
at C:\Users\snowl\OneDrive\Documents\a\Projets\08.5 - PokeWatch IA\node_modules\discord.js\src\structures\MessagePayload.js:151:46 {
constraint: 's.array(T).lengthGreaterThanOrEqual()',
given: [],
expected: 'expected.length >= 1'
}
It is talking about an array, but I can not figure which one
Pastebin
const { SlashCommandBuilder, ContainerBuilder, MessageFlags, Permis...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
duck
duck6mo ago
sections are specifically for if you want a text display with 1 thumbnail/button you're looking to put those buttons in action rows
d.js docs
d.js docs6mo ago
documentation suggestion for @clst.risuu: :method: ContainerBuilder#addActionRowComponents() discord.js@14.19.3 Adds action row components to this container.
! naaphÿ
! naaphÿOP6mo ago
oh okay did not know, I will remember thank you so I may use the ButtonBuilder instead of the ButtonAccessory ?
duck
duck6mo ago
I mean you were already using ButtonBuilder since that's what each b param is in each setButtonAccessory
! naaphÿ
! naaphÿOP6mo ago
okay I see thank you for your help
S A H i L
S A H i L6mo ago
npm list discord.js

Did you find this page helpful?