-
Notifications
You must be signed in to change notification settings - Fork 0
/
RNG.js
33 lines (29 loc) · 791 Bytes
/
RNG.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const config = require("../config");
module.exports = class RNG {
constructor(bot) {
this.bot = bot;
this.commandMap = {
rng: this.rng,
coinflip: this.coinflip
}
this.helpText = {
rng: `Returns a random number between 1 and 6 inclusive. Change the max number by specifying it in the command.`,
coinflip: `Flip a coin!`
}
}
rng(command, messageObject, bot) {
const splitMessage = command.split(" ");
let max = 6;
if (splitMessage.length > 1) {
max = Number(splitMessage[1]);
if (isNaN(max)) {
messageObject.channel.send(`That's not a number!`);
return;
}
}
messageObject.channel.send(Math.ceil(Math.random() * max));
}
coinflip(command, messageObject, bot) {
messageObject.channel.send(Math.random() > 0.5 ? 'Heads' : 'Tails');
}
}