-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathroll.js
22 lines (20 loc) · 846 Bytes
/
roll.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
async function command(chatClient, channel, args) {
const regex = /^[dD]\d+$/g;
if (args.length >= 1 && args[0].match(regex) ) {
const dieSize = args[0].substring(1, args[0].length);
const rollResult = 1 + Math.floor(Math.random() * dieSize);
chatClient.say(channel, args[0] + " = " + rollResult);
}
const peppergex = /^[pP]\d+$/g;
const dieSizeLimit = 10;
if (args.length >= 1 && args[0].match(peppergex) ) {
const dieSize = args[0].substring(1, args[0].length);
if (dieSize > dieSizeLimit) {
chatClient.say(channel, "More than " + dieSizeLimit + " would get too spammy!");
return;
}
const rollResult = 1 + Math.floor(Math.random() * dieSize);
chatClient.say(channel, "damaplEpper ".repeat(rollResult));
}
}
module.exports = { command };