I've been trying to push values into a JSON array but nothing has been happening. No error, no output, nothing. I've tried countless solutions by looking online but none of them worked. Here is my Javascript code:
const discord = require('discord.js');
const fs = require('fs');
const dataset = require('./data.json');
module.exports.run = async(client, message, args) => {
let blocks = args.join(' ').split('&');
let keyword = blocks[0];
let response = blocks[1];
var object = {
Keyword: keyword,
Response: response
};
dataset.push(object);
};
module.exports.help = {
name: 'aiadd'
};
Here is my JSON file:
[
{"Keyword":"hello","Response":"Hey there!"},
{"Keyword":"hey","Response":"Hiya!"},
{"Keyword":"hi","Response":"Hello!"},
{"Keyword":"hiya","Response":"Hi there buddy!"},
{"Keyword":"sup","Response":"Nothing much, just being a bot! What's up with you?"},
{"Keyword":"what's up","Response":"The sky lol."},
{"Keyword":"what is up","Response":"Not much really. I'm just vibing!"},
{"Keyword":"bye","Response":"See ya later!"}
]
Thanks!