For some reason when I try and call my command it returns [object Object],[object, Object]
fs.readFile(path.join(__dirname, "../moderation") + "/modlogs.json", "utf-8", function(err, data) { // read the JSON file
if (err) throw err; // throw error if applicable
var arrayOfObjects = JSON.parse(data); // parse the data
for (let i = 0; i < arrayOfObjects.warns.length; i++) { // loop through all keys in warns file
if (arrayOfObjects.warns[i].user_id === user.id) { // check if the user has already been warned
message.reply("User already warned. Kicking user."); // display kick
//message.guild.member(user).kick(); // kicks member
indexOfUser = arrayOfObjects.warns.findIndex(x => x.user_id == user.id); // find the index of the users object
//message.channel.sendMessage(indexOfUser);
message.channel.sendMessage("Before splicing" + arrayOfObjects.warns);
//arrayOfObjects.warns.splice(indexOfUser, 1); // remove the user from warns array
message.channel.sendMessage("After splicing" + arrayOfObjects.warns);
return;
};
};
The line //arrayOfObjects.warns.splice(indexOfUser, 1); // remove the user from warns array is supposed to delete that object from the warns array in my JSON file. However it doesn't, the console.logs were just to see what was getting outputed, and it seems like the values aren't getting through.