How to get Interaction choice name? (djs v14.7.1)

Hi, I have an interaction with some choices. Every choice has a name and a value and I need both of them. I know how to get the value but how do I get the name?
module.exports = {
data: new SlashCommandBuilder()
.setName("loop")
.setDescription("description")
.addStringOption(option =>
option
.setName('type')
.setDescription('another description')
.setRequired(true)
.addChoices(
{name: `Off`, value: `0`},
{name: `Track`, value: `1`},
{name: `Queue`, value: `2`},
{name: `Autoplay`, value: `3`}
)),
module.exports = {
data: new SlashCommandBuilder()
.setName("loop")
.setDescription("description")
.addStringOption(option =>
option
.setName('type')
.setDescription('another description')
.setRequired(true)
.addChoices(
{name: `Off`, value: `0`},
{name: `Track`, value: `1`},
{name: `Queue`, value: `2`},
{name: `Autoplay`, value: `3`}
)),
let mode = interaction.options.getString('type')
//with this i get `0` if Off is selected, but how should I do to get `Off`?
let mode = interaction.options.getString('type')
//with this i get `0` if Off is selected, but how should I do to get `Off`?
2 Replies
d.js toolkit
d.js toolkit17mo 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!
maybebas
maybebasOP17mo ago
(node v18.17.0)
Want results from more Discord servers?
Add your server