Issue with interaction.reply

The bot does reply if i use one command but the other one works in the background but doesnt give a reply
2 Replies
d.js toolkit
d.js toolkit7mo 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!
AI Rob
AI Rob7mo ago
if (interaction.commandName === "add") {

const userID = interaction.user.id;

fs.readFile(filePath, 'utf-8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}

try {
const jsonData = JSON.parse(data)
let userFound = false;

for (let i = 0; i < jsonData.User.length; i++){
if (jsonData.User[i].userID === userID){

jsonData.User[i].Tasks.push(interaction.options.get("task").value + " :x:")
const updatedJsonData = JSON.stringify(jsonData, null, 2);
fs.writeFile(filePath, updatedJsonData, 'utf8', (writeErr) => {
if (writeErr) {
console.error('Error writing to file:', writeErr);
} else {
console.log('JSON file updated successfully.');
interaction.reply("Added task successfully")
}
})
userFound = true;

break;
}
}

if (interaction.commandName === "add") {

const userID = interaction.user.id;

fs.readFile(filePath, 'utf-8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}

try {
const jsonData = JSON.parse(data)
let userFound = false;

for (let i = 0; i < jsonData.User.length; i++){
if (jsonData.User[i].userID === userID){

jsonData.User[i].Tasks.push(interaction.options.get("task").value + " :x:")
const updatedJsonData = JSON.stringify(jsonData, null, 2);
fs.writeFile(filePath, updatedJsonData, 'utf8', (writeErr) => {
if (writeErr) {
console.error('Error writing to file:', writeErr);
} else {
console.log('JSON file updated successfully.');
interaction.reply("Added task successfully")
}
})
userFound = true;

break;
}
}

damn formating got a bit messed up is there a timeout how long the bot can take to reply to a message
DCBot#3103 is online.
[nodemon] restarting due to changes...
JSON file updated successfully.
[nodemon] starting `node src/index.js`
DCBot#3103 is online.
DCBot#3103 is online.
[nodemon] restarting due to changes...
JSON file updated successfully.
[nodemon] starting `node src/index.js`
DCBot#3103 is online.
Thats the console output how do i fix this? thanks