I am making a balance system, and I created a give command. Whenever I give someone some money ($10 for example), their balance shows as "$10 [object Promise]". How can I remove "[object Promise]"?
Full command code:
if (command === 'give') {
if (!args[0]) return message.channel.send('how much are you gonna send?')
if (isNaN(args[0])) return message.channel.send('format: xd give [amount] [@user]')
const money = args[0];
const emb = new Discord.MessageEmbed()
.setColor('GRAY')
.setTitle('you gave them the $$')
.setDescription(`you gave ${message.mentions.users.first().username} the $$$$$$ (` + args[0] + ` to be exact)`)
.setTimestamp()
.setFooter('sent to pokimane');
message.channel.send(emb);
const money2 = moneyAmount - args[0];
if (isNaN(money2)) {
Number(money2);
}
moneydb.set(message.author.id, money2);
const uMA = moneydb.get(message.mentions.users.first().id);
const money3 = args[0] + uMA;
moneydb.set(message.mentions.users.first().id, money3);
}
// keyv connection
const moneydb = new Keyv('mysql://[user and pass]@localhost:3306/money');
Even the database has [object promise] at the end
If
moneydb
is a Keyv database as it appears in your question, then this line of code:puts a promise into uMA. You are apparently missing an
await
like this:So, when you do this:
And
uMA
is a promise, it tries to make them both into a string and you get the output that contains[object Promise]
.FYI, you can see from the Keyv documentation here that both
.set()
and.get()
return promises.