My code is something like this:
if (y[1] == "suggestion_channel") {
saveJson.servers[guild.id].suggestChannel = message.mentions.channels.first().id;
message.channel.send("Set suggest channel to: <#" + saveJson.servers[guild.id].suggestChannel + ">");
}
var save = JSON.stringify(saveJson);
fs.writeFileSync('./data.json', save);
Now it all works BUT the only part that doesnt work is the saving part.... The FULL code can be found Here Please be nice as I have been trying to fix this for HOURS thanks: :D
UPDATE: Just use fs.writeFile not sync!
The fs.writeFileSync()
accepts a callback function, maybe use that and see if there is any error.
Try something like this
fs.writeFileSync('./data.json', save,function(err) { if (err) { console.log(err); } });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.