0

Basically, I am trying to create a discord.js/quick.db economy system and I tried making a simple balance command, using a tutorial for guidance, and this command won't execute, but no errors are showing in the logs.

I tried researching how to do it, following other tutorials, but it just leads me back to this error. I have already installed all the required packages for this.

const Discord = require('discord.js')
const db = require('quick.db')

module.exports.run = async (bot, message, args) => {

    let bal = db.fetch(`money_${message.guild.id}_${message.author.id}`)

    if (bal === null) bal = 0;

    message.channel.send('You have a balance of `' + bal + '`')

}

I am receiving no errors, but the command just won't execute, I even searched the logs to make sure there were absolutely no errors, but nothing is showing up.

Syntle
  • 5,168
  • 3
  • 13
  • 34
Hippzo
  • 1
  • 1
  • You have a module.exports.help ? – PLASMA chicken Aug 24 '19 at 01:10
  • Unfortunately, without seeing the rest of your code it is quite impossible for us to determine what's wrong, my guess is that you are never actually running the code you posted in the first place. – Caltrop Aug 24 '19 at 09:36

2 Answers2

0

I have a similar script and mines working, I didn't use

if (bal === null) bal = 0

My code is this:

let goldAmount = db.get(`money_${message.author.id}`)

        let balEmbed = new Discord.RichEmbed()
            .setTitle(`${message.author.username}'s Gold`)
            .setColor([0,200,20])
            .setDescription(`${goldAmount} Gold`)

        await message.channel.send(balEmbed);

You don't need to send it as a RichEmbed, you can just do await message.channel.send(goldAmount);

ItamarD
  • 39
  • 2
  • 7
0

This works for me!

let user = message.mentions.members.first() || message.author;
let bal = db.fetch(`money_${message.guild.id}_${user.id}`)

if (bal === null) bal = 0;

let bank = await db.fetch(`bank_${message.guild.id}_${user.id}`)  
if (bank === null) bank = 0;

let moneyEmbed = new Discord.MessageEmbed()
    .setColor("RANDOM")  
    .setDescription(`**${user}'s Balance**\n\n__Pocket:__${bal}\n__Bank:__${bank}\n__Overall:__ ${bank + bal}`);  
message.channel.send(moneyEmbed);
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
mage3339
  • 11
  • 3