Add balance command for users to check their balance
This commit is contained in:
@@ -36,8 +36,8 @@ exports.createAccount = (_discordAccountId, callback) => {
|
||||
})
|
||||
}
|
||||
|
||||
exports.withdrawBalance = async (_withdrawAmount, _accountId, callback) => {
|
||||
userStorage.updateBalance('withdraw', _withdrawAmount, _accountId, async (err, result) => {
|
||||
exports.withdrawBalance = async (_withdrawAmount, _discordAccountId, callback) => {
|
||||
userStorage.updateBalance('withdraw', _withdrawAmount, _discordAccountId, async (err, result) => {
|
||||
if (err) return callback(err, undefined);
|
||||
|
||||
if(result) return callback(undefined, result);
|
||||
@@ -55,6 +55,22 @@ exports.verifyBalance = (_tokensToBeUsed, _accountId, callback) => {
|
||||
return callback(undefined, true);
|
||||
})
|
||||
}
|
||||
/**
|
||||
* Check the given account for the token balance
|
||||
*
|
||||
* @param {*} _discordAccountId
|
||||
* @param {*} callback
|
||||
*/
|
||||
exports.checkBalance = (_discordAccountId, callback) => {
|
||||
if (!_discordAccountId) return callback(new Error("No discord account given to check balance of"), undefined);
|
||||
userStorage.getRecordBy("discord_account_id", _discordAccountId, (err, accountRecord) => {
|
||||
if (err) return callback(err, undefined);
|
||||
|
||||
if (!accountRecord) return callback(new Error("No account record given"), undefined);
|
||||
|
||||
return callback(undefined, accountRecord.balance);
|
||||
})
|
||||
}
|
||||
|
||||
exports.insufficientTokensResponse = (interaction) => {
|
||||
log.DEBUG("INSUFFICIENT TOKENS RESPONSE")
|
||||
|
||||
Reference in New Issue
Block a user