The code i am currently using works, It is writing data to cell H1, and getting data from cell H2 in my google sheet. However when the command is ran twice in less than 1-2 minutes the bot crashes. This issue only occurs with the checkbl
command. All my other commands work perfectly fine and are able to be ran multiple times back to back without issues, so I’m curious as to what is causing this issue. Any feedback would be appreciated.
This is my current script:
async function blackList() {
const sheets = google.sheets({ version: "v4", auth });
const spreadsheetId = "mySheetId";
const sheetName = "BOTDATA";
const cells = ["H1"];
const valueInputOption = "USER_ENTERED";
const userInput = interaction.options.get('steamid').value;
await sheets.spreadsheets.values.update({
spreadsheetId,
range: `'${sheetName}'!${cells[0]}`,
resource: { values: [[userInput]] },
valueInputOption,
});
const obj = await sheets.spreadsheets.values.get({spreadsheetId, range: `'${sheetName}'!H2`});
const value = obj.data.values[0][0];
console.log(value);
return value
}
(async()=>{
if (interaction.commandName === 'checkbl') {
const value = await blackList()
const userInput = interaction.options.get('steamid').value;
const bl = new EmbedBuilder()
.setTitle('Blacklist Checker')
.setDescription(`${userInput} is ${value}`)
.setColor('Red')
.setThumbnail('https://i.imgur.com/9GKhYQf.png')
.setFooter({text: 'DroneOS', iconURL: 'https://i.imgur.com/9GKhYQf.png'})
.setTimestamp()
interaction.reply({ embeds: [bl]});
}
})()
This is the error i am recieving:
C:UsersDesktopDronenode_modules@discordjsrestdistindex.js:730
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[10062]: Unknown interaction
at handleErrors (C:UsersfreecDesktopDronenode_modules@discordjsrestdistindex.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:UsersDesktopDronenode_modules@discordjsrestdistindex.js:835:23)
at async _REST.request (C:UsersDesktopDronenode_modules@discordjsrestdistindex.js:1278:22)
at async ChatInputCommandInteraction.reply (C:UsersDesktopDronenode_modulesdiscord.jssrcstructuresinterfacesInteractionResponses.js:114:5) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [
{
title: 'Blacklist Checker',
description: 'STEAM_0:0:650756675 is Not Blacklisted',
color: 15548997,
thumbnail: [Object],
footer: [Object],
timestamp: '2024-08-06T07:23:25.829Z'
}
],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1270281039406698589/aW50ZXJhY3Rpb246MTI3MDI4MTAzOTQwNjY5ODU4OTpxWGxxN3lHRHJTYVh2cEt6NzVaWmxLVHRVdDlDdDI3UzdjOGNXd0xvekcwenV4bmFtVG9CQXVKZmVwTGJnemE5T0lPR0szNTREM2YyT3JzdjI1OGoyTUhwM3pHeW9Wdk4xbXdpcEdmMm1FMGRUeTdvU3RaV3JhM1FvMWNqc2FjVg/callback'
}
Node.js v20.15.1
[nodemon] app crashed - waiting for file changes before starting...