switched nedb to nedb-promises (#37)
* breaking change: switched to nedb-promises * Linting * some dev dependencies * more tests * updated package version * bug fixing * changed isNaN to isString * (fix) args[0]
This commit is contained in:
@ -1,24 +1,28 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const globals = require('../globals');
|
||||
|
||||
const { roll } = require('@dsabot/Roll');
|
||||
const { findMessage }= require('@dsabot/findMessage');
|
||||
const { findMessage } = require('@dsabot/findMessage');
|
||||
const { DiceRegex } = require('../globals');
|
||||
|
||||
module.exports = {
|
||||
name: 'roll',
|
||||
description: 'Lass die Würfel rollen. Benötigt wird die Anzahl sowie die Augenzahl auf den Würfeln.',
|
||||
aliases: ['r'],
|
||||
usage: '<Anzahl> w <Augenzahl>',
|
||||
needs_args: true,
|
||||
async exec(message, args) {
|
||||
let params = args.join('').split(globals.DiceRegex);
|
||||
if ( params.length >= 2 ) {
|
||||
const Bonus = parseInt(params[2]) || 0;
|
||||
const numberOfDice = parseInt( params[0] );
|
||||
const diceValues = parseInt( params[1] );
|
||||
const result = roll( numberOfDice, diceValues, message.author.tag );
|
||||
let total = (Bonus ? Bonus + result.sum : result.sum)
|
||||
message.reply(`${findMessage('ROLL')} ${result.dice.join(', ')} `+
|
||||
`(Gesamt: ${result.sum}${Bonus ? `+${Bonus}=${total}` : ``})` );
|
||||
}
|
||||
},
|
||||
name: 'roll',
|
||||
description:
|
||||
'Lass die Würfel rollen. Benötigt wird die Anzahl sowie die Augenzahl auf den Würfeln.',
|
||||
aliases: ['r'],
|
||||
usage: '<Anzahl> w <Augenzahl>',
|
||||
needs_args: true,
|
||||
async exec(message, args) {
|
||||
const params = args.join('').split(DiceRegex);
|
||||
if (params.length >= 2) {
|
||||
const Bonus = parseInt(params[2], 10) || 0;
|
||||
const numberOfDice = parseInt(params[0], 10);
|
||||
const diceValues = parseInt(params[1], 10);
|
||||
const result = roll(numberOfDice, diceValues, message.author.tag);
|
||||
const total = Bonus ? Bonus + result.sum : result.sum;
|
||||
message.reply(
|
||||
`${findMessage('ROLL')} ${result.dice.join(', ')} ` +
|
||||
`(Gesamt: ${result.sum}${Bonus ? `+${Bonus}=${total}` : ``})`
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user