I am creating a discord bot and I have 2 issues.
Issue One:
In my script i am trying to get the users response to :
interaction.options.get('steamid').value;
and store it in the variable userInput
.
Once stored i want to write the stored response to my google sheet in sheet BOTDATA!H1.
The code works when i set const userInput = interaction.options.get('steamid').value;
inside the function. Only when i use the ‘/checkbl’ command. If i use any other command i receive an error.
Issue Two: Any command that i use, regardless if it is the ‘/checkbl’ command or not will write `sample value` to the sheet BOTDATA!H1.
This is my current script:
async function blackList() {
const sheets = google.sheets({ version: "v4", auth });
const spreadsheetId = "1lEB9fEqZUNtR0Tq-gzHVVaQ2eQvxsuiwXSTW3VGC2xw";
const sheetName = "BOTDATA";
const cells = ["H1"];
const valueInputOption = "USER_ENTERED";
const userInput = "sample value";
const result = await sheets.spreadsheets.values.update({
spreadsheetId,
range: `'${sheetName}'!${cells[0]}`,
resource: { values: [[userInput]] },
valueInputOption,
});
console.log(result.data);
}
blackList();
(async()=>{
if (interaction.commandName === 'checkbl') {
const userInput = interaction.options.get('steamid').value;
const bl = new EmbedBuilder()
.setTitle('Blacklist Checker')
.setDescription(`${userInput} is`)
.setColor('Red')
.setThumbnail('https://i.imgur.com/9GKhYQf.png')
.setFooter({text: 'DroneOS', iconURL: 'https://i.imgur.com/9GKhYQf.png'})
.setTimestamp()
interaction.reply({ embeds: [bl]});
}
})()
I would like to solve both my issues stated above. Along side this i would like ‘userInput’ to write to cell H1 and i want to read cell H2 in the same function. This way i can set the response to:
.setDescription(`${userInput} is ${H2}`)
on my discord bot. Thanks for any help.