Skip to content

Commit

Permalink
Fixed donations being parsed as an integer and losing precision
Browse files Browse the repository at this point in the history
closes #2520
  • Loading branch information
gmt2001 committed Jul 23, 2021
1 parent 09d757f commit adcc988
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions javascript-source/discord/handlers/streamlabsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
donationJson = new JSONObject(donationJsonStr),
donationID = donationJson.get("donation_id"),
donationCurrency = donationJson.getString("currency"),
donationAmount = donationJson.getString("amount"),
donationAmount = parseFloat(donationJson.getString("amount")),
donationUsername = donationJson.getString("name"),
donationMsg = donationJson.getString("message"),
s = message;
Expand All @@ -71,11 +71,11 @@
}

if (s.match(/\(amount\)/g)) {
s = $.replace(s, '(amount)', parseInt(donationAmount).toFixed(2).toString());
s = $.replace(s, '(amount)', donationAmount.toFixed(2).toString());
}

if (s.match(/\(amount\.toFixed\(0\)\)/)) {
s = $.replace(s, '(amount.toFixed(0))', parseInt(donationAmount).toFixed(0).toString());
s = $.replace(s, '(amount.toFixed(0))', donationAmount.toFixed(0).toString());
}

if (s.match(/\(currency\)/g)) {
Expand Down
4 changes: 2 additions & 2 deletions javascript-source/discord/handlers/tipeeeStreamHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
}

if (s.match(/\(amount\)/)) {
s = $.replace(s, '(amount)', parseInt(donationAmount.toFixed(2)));
s = $.replace(s, '(amount)', donationAmount.toFixed(2));
}

if (s.match(/\(amount\.toFixed\(0\)\)/)) {
s = $.replace(s, '(amount.toFixed(0))', parseInt(donationAmount.toFixed(0)));
s = $.replace(s, '(amount.toFixed(0))', donationAmount.toFixed(0));
}

if (s.match(/\(message\)/)) {
Expand Down
4 changes: 2 additions & 2 deletions javascript-source/handlers/tipeeeStreamHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
}

if (s.match(/\(amount\)/)) {
s = $.replace(s, '(amount)', parseInt(donationAmount.toFixed(2)));
s = $.replace(s, '(amount)', donationAmount.toFixed(2));
}

if (s.match(/\(amount\.toFixed\(0\)\)/)) {
s = $.replace(s, '(amount.toFixed(0))', parseInt(donationAmount.toFixed(0)));
s = $.replace(s, '(amount.toFixed(0))', donationAmount.toFixed(0));
}

if (s.match(/\(message\)/)) {
Expand Down

0 comments on commit adcc988

Please sign in to comment.