#Pretty basic (I know), but how would I add a user input to a slash command using this type of syntax
1 messages ยท Page 1 of 1 (latest)
yeah
like e.g text to echo
and then it sends that text back in a message
I want to basically access it in the async execute function
You have to duplicate your .addStringOption and modify the name. Then, you don't need to pass it, you will get the parameter like you wrote at line 15
oh shit really?
hmm
alright one second lemme try it out :)
Can I access it like this then @crimson hollow ?
.getString("input")
Everything inside .addStringOption was good in the previous screenshot
The modification happens at line 15
sorry this is literally my first time EVER using discord.js - I am coming from a solely discord.py background ๐
alright
If you copy-paste the code next time, rather than screenshoot, I could modify it for you
lmao alr sorry
ok am still confused
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!')
// Add an option to accept user input
.addStringOption(option =>
option.setName('input')
.setDescription("The input to echo back")
.setRequired(true)
)
.getString("input"),
async execute(interaction) {
/* const ping = interaction.options.getString('ping');
return interaction.reply(ping); */
},
};
where the hell would I put the thing to get the thing?! 
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!')
// Add an option to accept user input
.addStringOption(option =>
option.setName('input')
.setDescription("The input to echo back")
.setRequired(true)
)
async execute(interaction) {
console.log(interaction.options.getString('input'));
/* const ping = interaction.options.getString('ping');
return interaction.reply(ping); */
},
};
If you were writing it like:
const { SlashCommandBuilder } = require('@discordjs/builders');
let parameter_name = "input";
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!')
// Add an option to accept user input
.addStringOption(option =>
option.setName(parameter_name)
.setDescription("The input to echo back")
.setRequired(true)
)
async execute(interaction) {
console.log(interaction.options.getString(parameter_name));
/* const ping = interaction.options.getString('ping');
return interaction.reply(ping); */
},
};
It would make even more sense
ohhh alr
thanks btw - it worked good :D
oh uh
@crimson hollow
modified it a bit
and it is scuffed now
why is that?
This file looks good. Also it looks like the error originates in some other place