roolthedice
Version:
A CLI program to rool dices for RPG's or not
20 lines (14 loc) • 418 B
JavaScript
const fs = require('fs');
const playSound = require('play-sound')((opts = {}));
function playDiceSound() {
const soundsPath = `${__dirname}/sounds/`;
const diceSounds = fs.readdirSync(soundsPath);
const sound =
soundsPath + diceSounds[Math.floor(Math.random() * diceSounds.length)];
playSound.play(sound, (err) => {
if (err) {
console.log(err);
}
});
}
module.exports = playDiceSound;