2

Me and a friend are making a discord bot, and added a warning command to warn users.

All was going well, and when we tested the deleting a warning it seemed fine. I then tried to delete all the warnings one by one, when we came across a problem. It wont delete the last warning in the array, the 1st, 2nd, 3rd etc? Thats fine, just the last index that isnt working.

Our code is like this:

list = data.warns//a list of JSON format warnings
console.log(list)//shows the value is in the list
console.log(list[index])//shows the value
delete list[index]
console.log(list)//shows its gone
data.warns = list;
console.log(data.warns)//shows the value is still no longer present
data.save().catch(blah blah)//no error is caught, and nothing crashes, it proceeds to send a message to the channel after this

but then the value at index is still there in the database as if it didn't save it, but only if the index is the last item in the array.

We have been stuck on this for over an hour and I now remember why I hate programming.

Comments
Add Comment