Skip to content

Commit

Permalink
fix(users): return bits correctly (#2364)
Browse files Browse the repository at this point in the history
Fixes #2362
  • Loading branch information
sogehige committed Jul 1, 2019
1 parent 1422263 commit 0454587
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion public/pages/viewers/edit.html
Expand Up @@ -120,7 +120,7 @@
<td scope="row">{{ moment(bits.timestamp).format('LLL') }}</td>
<td>
<input type="number" min="0" v-model="bits.amount" v-if="bits.editation" class="form-control">
<strong v-else>{{ bits.amount }}</strong>
<strong v-else>{{ Number(bits.amount) }}</strong>
</td>
<td>
<textarea v-model="bits.message" class="form-control" v-if="bits.editation"></textarea>
Expand Down
2 changes: 1 addition & 1 deletion src/bot/systems/userinfo.ts
Expand Up @@ -254,7 +254,7 @@ class UserInfo extends System {
if (message.includes('$bits')) {
const idx = message.indexOf('$bits');
const bits = await global.db.engine.find('users.bits', { id: opts.sender.userId });
let bitAmount = bits.map(o => o.amount).reduce((a, b) => a + b, 0);
let bitAmount = bits.map(o => Number(o.amount)).reduce((a, b) => a + b, 0);
message[idx] = `${bitAmount} ${getLocalizedName(bitAmount, 'core.bits')}`;
}
sendMessage(message.join(this.formatSeparator), opts.sender, opts.attr);
Expand Down
2 changes: 1 addition & 1 deletion src/bot/users.js
Expand Up @@ -269,7 +269,7 @@ class Users extends Core {

for (const v of viewers) {
_.set(v, 'stats.tips', v.tips.map((o) => global.currency.exchange(o.amount, o.currency, global.currency.mainCurrency)).reduce((a, b) => a + b, 0));
_.set(v, 'stats.bits', v.bits.map((o) => o.amount).reduce((a, b) => a + b, 0));
_.set(v, 'stats.bits', v.bits.map((o) => Number(o.amount)).reduce((a, b) => a + b, 0));
_.set(v, 'custom.currency', global.currency.mainCurrency);
_.set(v, 'points', (v.points[0] || { points: 0 }).points);
_.set(v, 'messages', (v.messages[0] || { messages: 0 }).messages);
Expand Down

0 comments on commit 0454587

Please sign in to comment.