aboutsummaryrefslogtreecommitdiff
path: root/marriage.js
diff options
context:
space:
mode:
Diffstat (limited to 'marriage.js')
-rw-r--r--marriage.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/marriage.js b/marriage.js
new file mode 100644
index 0000000..f4704b4
--- /dev/null
+++ b/marriage.js
@@ -0,0 +1,57 @@
+const common = require("./common.js")
+const google_images = require("free-google-images")
+let marriages = common.storageLoad("marriages") || {}
+
+module.exports = {
+ marry: common.requestCommand("marry another user", (msg, target) => {
+ const origin = msg.author.id
+
+ if (marriages[origin])
+ return `You are already married to <@!${marriages[origin]}>.`
+ else if (marriages[target])
+ return `<@!${target}> is already married to <@!${marriages[target]}>.`
+ else
+ msg.channel.send(`<@!${target}>: <@!${origin}> is proposing to you. Type !accept to accept or !deny to deny.`)
+ }, (msg, origin) => {
+ const target = msg.author.id
+
+ google_images.searchRandom("wedding")
+ .then(result => msg.reply(`Congratulations, <@!${target}> & <@!${origin}>, you are married. You may now kiss \\:)\n${result.image.url}`))
+
+ marriages[origin] = target
+ marriages[target] = origin
+ common.storageSave("marriages", marriages)
+ }),
+ divorce: {
+ func: msg => {
+ const user = msg.author.id
+ const partner = marriages[user]
+
+ if (partner) {
+ delete marriages[user]
+ delete marriages[partner]
+ common.storageSave("marriages", marriages)
+
+ msg.reply(`<@!${user}> divorced from <@!${partner}>.`)
+ } else {
+ msg.reply("You are not married.")
+ }
+ },
+ },
+ partner: {
+ func: (msg, [targetPing]) => {
+ const user = msg.author.id
+ const target = targetPing ? common.getPing(msg, targetPing, true) : user
+
+ if (target) {
+ const partner = marriages[target]
+ const are = user == target ? "You are" : `<@!${target}> is`
+
+ if (partner)
+ msg.reply(are + ` married to <@!${partner}>.`)
+ else
+ msg.reply(are + " not married.")
+ }
+ },
+ },
+}