a general question about autocomplete

how would I show an array in autocomplete? I want foo and bar to be the 2 options that will show upon respond, the question is how do I do it?
const arr = ['foo', 'bar'];
const arr = ['foo', 'bar'];
4 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
GeekCorner
GeekCorner12mo ago
You need to return an array including an object with name and value properties basically this:
[{
name: "Foo",
value: "option1"
},
{
name: "Bar",
value: "option2"
}]
[{
name: "Foo",
value: "option1"
},
{
name: "Bar",
value: "option2"
}]
Nounejm
Nounejm12mo ago
interaction.respond(arr.map((item) => ({ name: item, value: item })))
interaction.respond(arr.map((item) => ({ name: item, value: item })))
Nounejm
Nounejm12mo ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.