diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-03-05 19:18:38 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-03-05 19:18:38 +0100 |
commit | a25d1acd1d702287b6ca095a4079cf3f898cbe89 (patch) | |
tree | 552f6ccc15a082f9d662e7ff58bf2f954c0451e5 /marriage.js | |
download | furrybot-discord-a25d1acd1d702287b6ca095a4079cf3f898cbe89.tar.xz |
Initial commit
Diffstat (limited to 'marriage.js')
-rw-r--r-- | marriage.js | 57 |
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.") + } + }, + }, +} |