Files
dsabot/commands/roll.js
TobenderZephyr c179bdd0e0 Merge development into master (#5)
* fixing typos

* merge Dynamic commands (#3)

* Update README.md

* Update README.md

* fixing typos

* dynamically read new commands inside folder.

* eslint, update package.json due to moving files

Co-authored-by: Marcus Netz <marcus.netz@godyo.com>

* fix talent checking on empty arguments list

* Origin/message embed (#4)

* add first embedded message on tp.js

* move db from message commands

* fix missing arguments list, add need_args

* add global Message Replies.

* add more global Message Replies.

* more embedded messages. fixing string

* missing comma

* adding a few more strings on talents.

Co-authored-by: Marcus Netz <marcus.netz@godyo.com>

* fixing creating from json file

* bugfix: db not defined

* possible  fix for nonworking talent?

* fix double msg

* fix: aliases are now being used

* change: show command displays now some character attributes

* added various aliases to commands, added global strings.

Co-authored-by: Marcus Netz <marcus.netz@godyo.com>
2020-12-16 08:53:09 +01:00

36 lines
997 B
JavaScript

// eslint-disable-next-line no-unused-vars
const globals = require('../globals');
const Random = require('random');
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) {
Random.use(message.author.tag);
let msg;
let arguments = args.join('');
arguments = arguments.split(globals.DiceRegex);
if (arguments.length == 2) {
const numberOfDice = parseInt(arguments[0]);
const diceValues = parseInt(arguments[1]);
console.log(diceValues)
const roll = [];
for (let i = 0; i < numberOfDice; i++) {
const a = Random.int(1, diceValues);
roll.push(a);
}
if (numberOfDice == 1) {
msg = 'n';
}
else {
msg = ' ' + numberOfDice;
}
message.reply('Das sind deine Ergebnisse für deine' + msg + ' ' + diceValues + '-seitigen 🎲: ' + roll.join(', ') + '.');
}
},
};