aboutsummaryrefslogtreecommitdiff
path: root/random.js
blob: 11664391fa7dc749b033ccb28d1ebff9a335de07 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
const common = require("./common.js")
const sha1 = require("sha1")
const pseudoRandom = require("pseudo-random")

const german = require("./german.json")
const books = require("./books.json")

module.exports = {
	rolldice: {
		func: msg => msg.channel.send(`<@!${msg.author.id}> rolled a dice and got a ${1 + Math.floor(Math.random() * 6)}.`)
	},
	coinflip: {
		func: msg => msg.channel.send(`<@!${msg.author.id}> flipped a coin and got ${common.choose(["Heads", "Tails"])}.`)
	},
	choose: {
		func: (msg, options) => msg.reply(options.length < 2 ? "Not enough options" : `I choose ${common.choose(options)}.`)
	},
	uwu: {
		func: msg => msg.reply(
			new Array(1 + Math.floor(Math.random() * 10))
			.fill(null)
			.map(_ => new Array(3)
				.fill(common.choose(["u", "ü", "o", "ö"])[common.choose(["toUpperCase", "toLowerCase"])]())
				.fill("w"[common.choose(["toUpperCase", "toLowerCase"])](), 1, 2)
				.join("")
			)
			.join(" ")
		)
	},
	extinct: {
		func: (msg, [rawSpecies]) => {
			const species = common.uppercase((rawSpecies + (rawSpecies.slice(-1) == "s" ? "" : "s")).toLowerCase())
			msg.reply(`${species} are ${pseudoRandom(parseInt(sha1(species), 16) % 1e9).random() < 0.5 ? "" : "not "}extinct.`)
		}
	},
	german: {
		func: msg => msg.reply(common.choose(german))
	},
	book: {
		func: msg => msg.reply(common.choose(books))
	},
	video: {
		func: msg => msg.reply("https://youtube.com/watch?v=dQw4w9WgXcQ")
	},
}