From da568e5ae7fc115cf6e2c69d5d04d66a7f8d5ed6 Mon Sep 17 00:00:00 2001 From: ION606 Date: Thu, 12 May 2022 18:05:47 +0300 Subject: [PATCH] Added the 'balance' command --- commands/inventory/models/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/commands/inventory/models/app.js b/commands/inventory/models/app.js index ad14ae0..7847d30 100644 --- a/commands/inventory/models/app.js +++ b/commands/inventory/models/app.js @@ -72,7 +72,7 @@ function checkAndUpdateBal(dbo, item, message, args) { } else { let temp = doc[0]; dbo.updateOne({balance: temp.balance, rank: temp.rank, lastdayworked: temp.lastdayworked}, { $set: { balance: doc[0].balance -= icost }}); - message.reply("You have bought " + item.name + " for " + icost + "!"); + message.reply("You have bought " + item.name + " for $" + icost + "!"); return true; } }); @@ -161,6 +161,13 @@ function printInventory(dbo, message) { } +function getBalance(dbo, message) { + dbo.find({"balance": {$exists: true}}).toArray(function(err, doc) { + message.reply('Your current balance is $' + String(doc[0].balance)); + }); +} + + function getShop(message, args, items) { if (args.length == 0) { let temp = Formatters.codeBlock(items.map(i => `${i.sect}`).join(' ')); @@ -244,6 +251,8 @@ module.exports = { rank(dbo, message, xp_list); } else if (command == 'inventory') { printInventory(dbo, message); + } else if (command == 'balance') { + getBalance(dbo, message); } else { message.channel.send("'" + message.content + "' is not a command!"); }