]> git.lizzy.rs Git - furrybot-discord.git/blob - marriage.js
Add bad apple
[furrybot-discord.git] / marriage.js
1 const common = require("./common.js")
2 const google_images = require("free-google-images")
3 let marriages = common.storageLoad("marriages") || {}
4
5 module.exports = {
6         marry: common.requestCommand("marry another user", "is proposing to you", (msg, target) => {
7                 const origin = msg.author.id
8
9                 if (marriages[origin])
10                         return `You are already married to <@!${marriages[origin]}>.`
11                 else if (marriages[target])
12                         return `<@!${target}> is already married to <@!${marriages[target]}>.`
13         }, (msg, origin) => {
14                 const target = msg.author.id
15
16                 google_images.searchRandom("wedding")
17                         .then(result => msg.reply(`Congratulations, <@!${target}> & <@!${origin}>, you are married. You may now kiss \\:)\n${result.image.url}`))
18
19                 marriages[origin] = target
20                 marriages[target] = origin
21                 common.storageSave("marriages", marriages)
22         }),
23         divorce: {
24                 func: msg => {
25                         const user = msg.author.id
26                         const partner = marriages[user]
27
28                         if (partner) {
29                                 delete marriages[user]
30                                 delete marriages[partner]
31                                 common.storageSave("marriages", marriages)
32
33                                 msg.reply(`<@!${user}> divorced from <@!${partner}>.`)
34                         } else {
35                                 msg.reply("You are not married.")
36                         }
37                 },
38         },
39         partner: {
40                 func: (msg, [targetPing]) => {
41                         const user = msg.author.id
42                         const target = targetPing ? common.getPing(msg, targetPing, true) : user
43
44                         if (target) {
45                                 const partner = marriages[target]
46                                 const are = user == target ? "You are" : `<@!${target}> is`
47
48                                 if (partner)
49                                         msg.reply(are + ` married to <@!${partner}>.`)
50                                 else
51                                         msg.reply(are + " not married.")
52                         }
53                 },
54         },
55 }