From b49873e1d48b058de8a5314873522d2b7acc9b69 Mon Sep 17 00:00:00 2001 From: TobenderZephyr Date: Wed, 28 Apr 2021 13:23:23 +0200 Subject: [PATCH] Fix sum of roll (#24) * (fix) sum of dice rolls not displaying total result --- commands/Roll.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/Roll.js b/commands/Roll.js index 0fb4f91..eb71483 100644 --- a/commands/Roll.js +++ b/commands/Roll.js @@ -12,11 +12,13 @@ module.exports = { async exec(message, args) { let params = args.join('').split(globals.DiceRegex); if ( params.length >= 2 ) { - const Bonus = params[2] || 0; + const Bonus = parseInt(params[2]) || 0; const numberOfDice = parseInt( params[0] ); const diceValues = parseInt( params[1] ); const result = roll( numberOfDice, diceValues, message.author.tag ); - message.reply(`${findMessage('ROLL')} ${result.dice.join(', ')} (Gesamt: ${result.sum} + ${Bonus} = ${result.sum + Bonus})` ); + let total = (Bonus ? Bonus + result.sum : result.sum) + message.reply(`${findMessage('ROLL')} ${result.dice.join(', ')} `+ + `(Gesamt: ${result.sum}${Bonus ? `+${Bonus}=${total}` : ``})` ); } }, -}; \ No newline at end of file +};