How to get values from options other than .getString()?

Hello, I am extremely new here and this is my last option, I looked all over the documentation and the guide to get an answer on how do i get the values that the options return with no avail, im still in the Advanced command building section in the guide so i'm not that knowledgeable, im sure this question was asked many times but any help would be appreciated (this includes the values returned from choices)
5 Replies
d.js toolkit
d.js toolkit8mo 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 OP
Syjalo
Syjalo8mo ago
It's interaction.options.getX() X is the option type Do you have an error? Show it. Show your code too.
BrickInYourFace
BrickInYourFaceOP8mo ago
thank you, so does this include the values returned from choices too? i dont have any code in particular (i took the one in the guide for testing purposes)
const {SlashCommandBuilder} = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName('gifbot')
.setDescription('Sends a random gif!')
.addStringOption(option =>
option.setName('category')
.setDescription('The gif category')
.setRequired(true)
.addChoices(
{ name: 'Funny', value: 'gif_funny' },
{ name: 'Meme', value: 'gif_meme' },
{ name: 'Movie', value: 'gif_movie' },
)
),
async execute(interaction) {
const values = interaction.options.getString("values");
await interaction.reply(`/gif ${values}`);
}
}
const {SlashCommandBuilder} = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName('gifbot')
.setDescription('Sends a random gif!')
.addStringOption(option =>
option.setName('category')
.setDescription('The gif category')
.setRequired(true)
.addChoices(
{ name: 'Funny', value: 'gif_funny' },
{ name: 'Meme', value: 'gif_meme' },
{ name: 'Movie', value: 'gif_movie' },
)
),
async execute(interaction) {
const values = interaction.options.getString("values");
await interaction.reply(`/gif ${values}`);
}
}
so as im trying to understand. choices return a value that can be used in a particular way when the value is received, i can use it in my execute function
duck
duck8mo ago
the very next section of the guide after "Advanced command creation" is the "Parsing options" section which covers this
BrickInYourFace
BrickInYourFaceOP8mo ago
ah, thank you.
Want results from more Discord servers?
Add your server