]> git.lizzy.rs Git - furrybot-discord.git/blob - marriage.js
Initial commit
[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", (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                 else
14                         msg.channel.send(`<@!${target}>: <@!${origin}> is proposing to you. Type !accept to accept or !deny to deny.`)
15         }, (msg, origin) => {
16                 const target = msg.author.id
17
18                 google_images.searchRandom("wedding")
19                         .then(result => msg.reply(`Congratulations, <@!${target}> & <@!${origin}>, you are married. You may now kiss \\:)\n${result.image.url}`))
20
21                 marriages[origin] = target
22                 marriages[target] = origin
23                 common.storageSave("marriages", marriages)
24         }),
25         divorce: {
26                 func: msg => {
27                         const user = msg.author.id
28                         const partner = marriages[user]
29
30                         if (partner) {
31                                 delete marriages[user]
32                                 delete marriages[partner]
33                                 common.storageSave("marriages", marriages)
34
35                                 msg.reply(`<@!${user}> divorced from <@!${partner}>.`)
36                         } else {
37                                 msg.reply("You are not married.")
38                         }
39                 },
40         },
41         partner: {
42                 func: (msg, [targetPing]) => {
43                         const user = msg.author.id
44                         const target = targetPing ? common.getPing(msg, targetPing, true) : user
45
46                         if (target) {
47                                 const partner = marriages[target]
48                                 const are = user == target ? "You are" : `<@!${target}> is`
49
50                                 if (partner)
51                                         msg.reply(are + ` married to <@!${partner}>.`)
52                                 else
53                                         msg.reply(are + " not married.")
54                         }
55                 },
56         },
57 }