I’m using discord.js and quick.db and was trying to figure out if there was a way to update a variable for each person every 5 minutes. For example, if someone had three workers they would earn 15 dollars every 5 minutes. At the same time if someone had 1 worker they would earn only 5 dollars every 5 minutes. Is this possible?
This is the code to make it run every five minutes:
setInterval(function() {
client.commands.get('mupdates').execute(message, Discord);
console.log('main')
}, 15000);
This is the code that is being called:
const db = require('quick.db');
module.exports = {
name: 'mupdates',
description: 'updates variables every five minutes',
execute: async (message, Discord) => {
let target = message.mentions.members.first() || message.author
let workers = await db.fetch(`workers_${target}`)
console.log('eeeeeeeeeeeeee')
db.add(`newmoney_${target}`, workers)
console.log(`gave ${workers} money to ${target}`)
}
}