Delete list command deletes all elements from the array

I’m trying to make a series of commands to make a list: !addlist, !viewlist, and !deletelist.

For the list I am using a JSON file:

  "listContent": []

And for the command file for the !deletelist command:

const Discord = require('discord.js')
const list = require('../list.json')
const fs = require('fs')

module.exports = {
    name: 'deletelist',
    execute(message, args) {
        var rawContent = fs.readFileSync('list.json')
        var content = JSON.parse(rawContent)
        var contentList = content.listContent
        var deletedOne = contentList[parseInt(args[0])]

        content.listContent.splice(deletedOne)`${deletedOne} has been deleted!`)

        fs.writeFile('list.json', JSON.stringify(content), function writeJSON(err) {
            if (err) return console.log(err);

My problem is that instead of deleting the specified element in the array, it deletes all of them. I don’t get an error or anything, my list just becomes empty.

27 thoughts on “Delete list command deletes all elements from the array”

  1. 702199 958559Hi there! I just wish to give an enormous thumbs up for the nice info youve proper here on this post. I shall be coming once more to your weblog for extra soon. 259645

  2. Pingback: psy-
  3. I do not even understand how I ended up here, but I thought this submit
    was great. I do not recognise who you’re but certainly
    you are going to a famous blogger if you aren’t already. Cheers!

  4. Hi, I think your blog might be having browser compatibility issues.
    When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer, it has
    some overlapping. I just wanted to give you a quick
    heads up! Other then that, excellent blog!

  5. whoah this blog is fantastic i really like reading your articles.

    Stay up the good work! You recognize, lots of individuals are
    hunting around for this information, you can aid them greatly.

  6. I would like to thank you for the efforts
    you have put in writing this site. I am hoping to see the same
    high-grade content from you later on as well. In fact, your creative writing abilities has encouraged me to
    get my very own blog now 😉

  7. 162061 208987Superb read, I just passed this onto a friend who was performing some research on that. And he in fact bought me lunch since I located it for him smile So let me rephrase that: Thank you for lunch! 549299


Leave a Comment