Having trouble getting values using quick.db in discord.js (Typescript)

675 Views Asked by At

I am writing a discord bot in typescript and can't seem to retrieve data. I can see the user ids in the JSON.sqlite file but I can't figure out why it returns null when I retrieve data. If you want to see my code I have it on Pastebin with a couple of comments.

2

There are 2 best solutions below

7
On

The line

console.log(economy.get(`${msg.author.id}.money`))

is wrong. You probably want

console.log(economy.get(msg.author.id).money)

Reason: ${} is making a template string, which indeed puts the variable into a string, however, you don't need to do this as passing in the value in the first place will do it anyways. However, you are trying to access the money property from msg.author_id, which doesn't exist. Therefore, it returns null and SQLite can't find a null entry.

2
On

quick.db needs async/await because it uses promise-mysql and returns a promise.