AI Rob
AI Rob
DIAdiscord.js - Imagine an app
Created by AI Rob on 12/12/2023 in #djs-questions
Issue with interaction.reply
thanks
8 replies
DIAdiscord.js - Imagine an app
Created by AI Rob on 12/12/2023 in #djs-questions
Issue with interaction.reply
how do i fix this?
8 replies
DIAdiscord.js - Imagine an app
Created by AI Rob on 12/12/2023 in #djs-questions
Issue with interaction.reply
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
8 replies
DIAdiscord.js - Imagine an app
Created by AI Rob on 12/12/2023 in #djs-questions
Issue with interaction.reply
is there a timeout how long the bot can take to reply to a message
8 replies
DIAdiscord.js - Imagine an app
Created by AI Rob on 12/12/2023 in #djs-questions
Issue with interaction.reply
damn formating got a bit messed up
8 replies
DIAdiscord.js - Imagine an app
Created by AI Rob on 12/12/2023 in #djs-questions
Issue with interaction.reply
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;
}
}

8 replies