So I'm using discord.js and am trying to get a block command to store its value in an array. In other words, when I do /block It will ignore that person, but I want it to store it in a file so it stays after restarting. My current code is below:
//at the top
var { blockedUsers } = require('./blocked.json')
//in the command listener
if (command == 'block') {
let user = message.mentions.users.first();
if (user && !blockedUsers.includes(user.id)) blockedUsers.push(user.id);
message.channel.send(`blocked!`)
}
blocked.json:
{
"blockedUsers": []
}
This works fine, but after restarting the bot, the blocked list clears. How can I get it to store it in the file so that it stays after restarting?