1 const common = require("./common.js")
2 const google_images = require("free-google-images")
3 let marriages = common.storageLoad("marriages") || {}
6 marry: common.requestCommand("marry another user", "is proposing to you", (msg, target) => {
7 const origin = msg.author.id
10 return `You are already married to <@!${marriages[origin]}>.`
11 else if (marriages[target])
12 return `<@!${target}> is already married to <@!${marriages[target]}>.`
14 const target = msg.author.id
16 google_images.searchRandom("wedding")
17 .then(result => msg.reply(`Congratulations, <@!${target}> & <@!${origin}>, you are married. You may now kiss \\:)\n${result.image.url}`))
19 marriages[origin] = target
20 marriages[target] = origin
21 common.storageSave("marriages", marriages)
25 const user = msg.author.id
26 const partner = marriages[user]
29 delete marriages[user]
30 delete marriages[partner]
31 common.storageSave("marriages", marriages)
33 msg.reply(`<@!${user}> divorced from <@!${partner}>.`)
35 msg.reply("You are not married.")
40 func: (msg, [targetPing]) => {
41 const user = msg.author.id
42 const target = targetPing ? common.getPing(msg, targetPing, true) : user
45 const partner = marriages[target]
46 const are = user == target ? "You are" : `<@!${target}> is`
49 msg.reply(are + ` married to <@!${partner}>.`)
51 msg.reply(are + " not married.")