diff --git a/libStorage.js b/libStorage.js index 1ce3cb7..f554e79 100644 --- a/libStorage.js +++ b/libStorage.js @@ -202,11 +202,11 @@ exports.UserStorage = class UserStorage extends Storage { switch(_updateType){ case "withdraw": // Code here to withdraw funds - sqlQuery = `UPDATE ${this.dbTable} SET balance=balance-${_updateAmount};`; + sqlQuery = `UPDATE ${this.dbTable} SET balance=balance-${_updateAmount} WHERE discord_account_id = ${_account_id};`; break; case "deposit": // Code here to withdraw funds - sqlQuery = `UPDATE ${this.dbTable} SET balance=balance+${_updateAmount};`; + sqlQuery = `UPDATE ${this.dbTable} SET balance=balance+${_updateAmount} WHERE discord_account_id = ${_account_id};`; break; default: log.ERROR('Update type not valid: ', _updateType); @@ -215,10 +215,12 @@ exports.UserStorage = class UserStorage extends Storage { if(!sqlQuery) return callback(new Error("SQL Query empty"), undefined); + log.DEBUG("Updating Balance with SQL Query: ", sqlQuery); + runSQL(sqlQuery, this.connection, (err, rows) => { if (err) return callback(err, undefined); - if (rows?.affectedRows > 0) return callback(undefined, rows); - return callback(undefined, undefined); + if (!rows?.affectedRows > 0) return callback(new Error("Error updating Balance", rows), undefined); + return callback(undefined, rows); }) } }