Creating an economy system, looking for solutions to save

Hello, I have recently made a coins system for my project sunshrine-kiwibot and I need assistance. I am using module FS and a JSON file called coins.json. Everytime a user gets coins, I have to refresh the project so that it saves the new coins. Are there any alternatives or solutions instead of refreshing ever time?

use json.stringify to save without refreshing

I did do a json.stringify:
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => { if (err) console.log(err) })

@HeemPlayz i did the json.stringify but still I need to refresh to get the new info

Maybe use a SQLite database with

@yogurtsyum i dunno how to deal with databases yet…

Alright, well just so you know the database adapter I linked is super easy if you check out the npm page. Can you share some code of how you’re doing it right now so we can help more?

Maybe you might enjoy reading ~hello-sqlite, and imagine that you’re storing and retreiving coins instead of storing and retreiving dreams?

Mabye something like this?

UPDATE  "economy"
SET  coins  =  coins - 1
WHERE  name = ?;


1 Like

here: `module.exports = {
name: ‘event’,
run: async (client, message, args) => {

const { MessageEmbed } = require('discord.js')

const settings = require('../../settings.json')


if (!settings.owners.includes( return message.reply('you don\'t have permission to use this command...').then(m => m.delete({ "timeout": 1500 }))

const fs = require('fs');

const coins = require(’…/…/coins.json’)

  let randomNum = Math.floor(Math.random() * 1000000)
  const { generateKey } = require('../../functions.js')
  let key = generateKey()
  let number = `${randomNum}`
         const event = new MessageEmbed()
   .setTitle('Hourly coins event!')
   .setDescription(`First one to type \`\`${key}\`\` wins \`\`${number}\`\` coins!`)

  let channel = message.mentions.channels.first() ||;


   let filter = m => !;

   .then(collected => {
       if(collected.first().content === key) {
       let winnerembed =  new MessageEmbed()
       .setTitle('Someone claimed it!')
       .setDescription(`${collected.first().author} was the first to type \`\`${key}\`\`!`);
         if(!coins[collected.first()]) coins[collected.first()] = {
           coins: number
         if(coins[collected.first()].coins > 0 || coins[collected.first()].coins == 0) coins[collected.first()] = {
           coins: coins[collected.first()].coins + '' + number

       fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
         if (err) console.log(err)
          } else return;