Type issues with .addChoices()

I am attempting to add choices to a string option, and this error is a little confusing. See what I mean:
option.setName("type").setDescription("Choose whether to snipe an entire message or a message edit.")
.addChoices([
{
name: "Message",
value: "msg"
},
{
name: "Edit",
value: "edit"
}
])
)
option.setName("type").setDescription("Choose whether to snipe an entire message or a message edit.")
.addChoices([
{
name: "Message",
value: "msg"
},
{
name: "Edit",
value: "edit"
}
])
)
The error: Argument of type '{ name: string; value: string; }[]' is not assignable to parameter of type 'APIApplicationCommandOptionChoice<string>'. Type '{ name: string; value: string; }[]' is missing the following properties from type 'APIApplicationCommandOptionChoice<string>': name, value
Solution:
addChoices has a spread syntax for the array type, so remove the square brackets and it will work.
Jump to solution
6 Replies
Solution
KB
KB7mo ago
addChoices has a spread syntax for the array type, so remove the square brackets and it will work.
PossiblySebo
PossiblySebo7mo ago
i m a dumbass
KB
KB7mo ago
Dw I forget all the pepeCry
PossiblySebo
PossiblySebo7mo ago
thx
PossiblySebo
PossiblySebo7mo ago
is there a list of all of the events from the sapphireclient class? such as command cooldown and stuff
KB
KB7mo ago
Should create a new post if you have more questions, but you can find them on the Events export from @sapphire/framework