Hello! I have a command that will ask the user for 2 inputs, how can I now grab this 2 inputs the user has typed and add it to an array as an object inside of a JSON file?
I mean, every time the command is run I want it to create a new object following this format: const object{name:"input1", artist:"input2"} and then save it to an array that I have inside of a JSON file.
This is my command and then an example of what the json should look like:
module.exports={
data: new SlashCommandBuilder()
.setName('test')
.setDescription('Testing options')
.addStringOption(option =>
option.setName('input')
.setDescription('The input to test')
.setRequired(true))
.addStringOption(option =>
option.setName('input2')
.setDescription('The second input to test')
.setRequired(true)),
async execute(interaction){
let input1 = interaction.options.getString('input');
let input2 = interaction.options.getString('input2');
await interaction.reply(input1 + ` - ` + input2)},
};
//THIS IS A DIFFERENT FILE, A .JSON FILE. THE "DIE FOR YOU" AND "FEAR" AND INPUT1 AND THE "THE WEEKND" AND "KENDRICK LAMAR" ARE INPUT2.
[
{
"name":"Die for You",
"artist":"The Weeknd"
},
{
"name":"FEAR",
"artist":"Kendrick Lamar"
}
]