Skip to content

Commit

Permalink
/diceroll command (#1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
NouSixXD authored Oct 15, 2024
1 parent 70a466e commit 0f7cb47
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Games/core/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,48 @@ module.exports = class Player {
return;
}
}
return;
case "diceroll":

if (this.dicerollCooldown == true) {
this.sendAlert(`This command has a 5 seconds cooldown, wait plz`);
return;
}
this.dicerollCooldown = true
setTimeout(() => {
this.dicerollCooldown = false
}, 5000);

let amountOfRolls = 1
let diceType = 6;

if (cmd.args.length == 1) {
amountOfRolls = cmd.args[0];
} else if (cmd.args.length >= 2) {
amountOfRolls = cmd.args[0];
diceType = cmd.args[1];
}

if (amountOfRolls > 10) {
amountOfRolls = 10;
}

let rollsOutput = `${this.name} rolled d` + diceType + ` dice ` + amountOfRolls + ` times and got `;

for (let i = 0; i < amountOfRolls; i++) {

let roll = Math.floor(Math.random() * diceType) + 1;

if (i === amountOfRolls - 1) {
rollsOutput += roll + '.';
} else {
rollsOutput += roll + ', ';
}

}

this.game.sendAlert(rollsOutput);

return;
}

Expand Down
4 changes: 4 additions & 0 deletions react_main/src/constants/commandList.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ export const commandList = {
input: "Role name",
description: "Used to display role descriptions in chat.",
},
"/diceroll": {
input: "Amount, Dice Type",
description: "Rolls dice, results are shown to everyone.",
},
};

0 comments on commit 0f7cb47

Please sign in to comment.