'How can I edit a config file in discord.js?

How can I edit a config.json file? I tried

const config = require("./config.json");
config.set("status", "online");

but it doesn't work.



Solution 1:[1]

You need to read in the file with something like fs.readFile then modify the content of the file and write back to it with fs.writeFile.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DᴀʀᴛʜVᴀᴅᴇʀ