Skip to content

Commit 74946ca

Browse files
committed
Show current balance before updating
1 parent 6175952 commit 74946ca

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

config/set-balance.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ const Balance = require('~/models/Balance');
5656
silentExit(1);
5757
}
5858

59-
if (!amount) {
60-
amount = await askQuestion('amount:');
61-
}
62-
// Validate the amount
63-
if (!amount) {
64-
console.red('Error: Please specify an amount!');
65-
silentExit(1);
66-
}
67-
6859
// Validate the user
6960
const user = await User.findOne({ email }).lean();
7061
if (!user) {
@@ -74,6 +65,22 @@ const Balance = require('~/models/Balance');
7465
console.purple(`Found user: ${user.email}`);
7566
}
7667

68+
let balance = await Balance.findOne({ user: user._id }).lean();
69+
if (!balance) {
70+
console.purple('User has no balance!');
71+
} else {
72+
console.purple(`Current Balance: ${balance.tokenCredits}`);
73+
}
74+
75+
if (!amount) {
76+
amount = await askQuestion('amount:');
77+
}
78+
// Validate the amount
79+
if (!amount) {
80+
console.red('Error: Please specify an amount!');
81+
silentExit(1);
82+
}
83+
7784
/**
7885
* Now that we have all the variables we need, lets set the balance
7986
*/

0 commit comments

Comments
 (0)