#add command choices from array or map
1 messages · Page 1 of 1 (latest)
show the code you have so far
when you use for..in in an array servers will be the index
so that wouldnt even work
idk what you're trying to achieve, can you show what the array looks like?
that's if you used for..of, not for..in
so you want to add the first element of every array as the choice name and value?
yes and i see for in and of are different i didnt notice
so choice x = array[0], array[0]
for all in serverConfigs
.addChoices(...serverConfigs.map((c) => c[0]))
what is that supposed to do? it wont run
show the final code
you didn't close the addStringOption call
that didnt change anything
ZodError: [
{
"code": "invalid_type",
"expected": "array",
"received": "string",
"path": [],
"message": "Expected array, received string"
}
is there not a way to just add a map object as my choices
definitely changed something, given that your code didn't even run in the first place
ah yeah i see, mb
.addChoices(...serverConfigs.map((c) => [c[0], c[0]]))
lol now it just prints the error twice
ZodError: [
{
"code": "invalid_type",
"expected": "array",
"received": "string",
"path": [
0
],
"message": "Expected array, received string"
},
{
"code": "invalid_type",
"expected": "array",
"received": "string",
"path": [
1
],
"message": "Expected array, received string"
}
]
you're probably still using an older version of builders then, remove the ...
i installed today
yeah ignore, i was already thinking about v14
v13 still uses an older version of builders
for that specific method, you'll have to use ...
ok im just worried cause 13 broke all my apps and now it seems 14 will to