2

I am trying to make an economy bot using quick.db, but for some reason, its .get() function doesn't get recognised. I have looked into the library's documentation to check if it really does exist and it does. This is my code that gives the error, it is a simple balance check command.

module.exports = {
  name:'withdraw',
  execute(message, args){
    // pretty much the opposite of the deposit command :P
    const Discord = require("discord.js")
    const db = require("quick.db")
    let bank = db.get(`bank_${message.author}`)
    let bal = db.get(`balance_${message.author}`)
    
    let wt = args[1]
    
    db.add(`balance_${message.author}`, wt)
    db.subtract(`bank_${message.author}`, wt)

    const withdraw = new Discord.MessageEmbed()
    .setTitle(`Withdrawal`)
    .setDescription(`You have withdrawn ${wt} coins from your bank`)
    .setColor("RANDOM")
    message.channel.send(withdraw)
  },
};
Caladan
  • 2,261
  • 2
  • 6
  • 19
  • 1
    The [first page of the Quick.db website](https://quickdb.js.org/) shows `db` being set to `new QuickDb()`, not the entire module – Elitezen Oct 15 '22 at 20:44

1 Answers1

0

Try using db.fetch() instead of db.get()

module.exports = {
  name:'withdraw',
  execute(message, args){
    // pretty much the opposite of the deposit command :P
    const Discord = require("discord.js")
    const db = require("quick.db")
    let bank = db.fetch(`bank_${message.author}`)
    let bal = db.fetch(`balance_${message.author}`)
    
    let wt = args[1]
    
    db.add(`balance_${message.author}`, wt)
    db.subtract(`bank_${message.author}`, wt)

    const withdraw = new Discord.MessageEmbed()
    .setTitle(`Withdrawal`)
    .setDescription(`You have withdrawn ${wt} coins from your bank`)
    .setColor("RANDOM")
    message.channel.send(withdraw)
  },
};
reflextheone
  • 3
  • 1
  • 1