|
| 1 | +const Discord = require('discord.js') |
| 2 | +const colors = require('../lib/colors.json') |
| 3 | + |
| 4 | +exports.run = async (client, message, args) => { |
| 5 | + const user = message.mentions.users.first() || client.users.get(args[0]) |
| 6 | + if (!user) return message.channel.send('You must mention someone or give their ID!') |
| 7 | + if (user.bot === true) return message.channel.send('Don\'t marry bots. They have no feelings... trust me...') |
| 8 | + if (user === message.author || message.author.id === user.id) return message.channel.send('It really do be like that sometimes...') |
| 9 | + |
| 10 | + let proposerID = message.author.id |
| 11 | + let proposerName = message.author.username |
| 12 | + |
| 13 | + client.life.ensure(user.id, { |
| 14 | + member: user.id, |
| 15 | + spouse: 0, |
| 16 | + job: 0 |
| 17 | + }) |
| 18 | + |
| 19 | + client.life.ensure(message.author.id, { |
| 20 | + member: message.author.id, |
| 21 | + spouse: 0, |
| 22 | + job: 0 |
| 23 | + }) |
| 24 | + |
| 25 | + client.inventory.ensure(message.author.id, { |
| 26 | + member: message.author.id, |
| 27 | + rings: 0, |
| 28 | + petfood: 0, |
| 29 | + seeds: 0, |
| 30 | + }) |
| 31 | + |
| 32 | + const rings = client.inventory.get(message.author.id, 'rings') |
| 33 | + const spouse = client.life.get(message.author.id, 'spouse') |
| 34 | + const uSpouse = client.life.get(user.id, 'spouse') |
| 35 | + |
| 36 | + if (rings === 0) return message.channel.send('You do not have a wedding ring. Buy one in the shop.') |
| 37 | + if (spouse !== 0) return message.channel.send('You cannot have more than one spouse.') |
| 38 | + if (uSpouse !== 0) return message.channel.send(`${user.tag} already has a spouse.`) |
| 39 | + |
| 40 | + let embed = new Discord.RichEmbed() |
| 41 | + .setDescription(`**${user.tag}**, **${message.author.tag}** is asking for your hand in marriage, would you like to accept?`) |
| 42 | + |
| 43 | + const noEmoji = message.client.emojis.get('637573919204966410') |
| 44 | + message.channel.send(embed).then(message => { |
| 45 | + message.react('✅').then(() => message.react(noEmoji)); |
| 46 | + |
| 47 | + const filter = (reaction, sent) => { |
| 48 | + return ['✅', noEmoji].includes(reaction.emoji.name) && sent.id === user.id; |
| 49 | + }; |
| 50 | + |
| 51 | + const proposer = message.guild.members.get("id", proposerID) |
| 52 | + |
| 53 | + message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] }) |
| 54 | + .then(collected => { |
| 55 | + const reaction = collected.first() |
| 56 | + |
| 57 | + if (reaction.emoji.name === '✅') { |
| 58 | + client.life.set(proposerID, user.id, 'spouse') |
| 59 | + client.life.set(user.id, proposerID, 'spouse') |
| 60 | + client.inventory.set(proposerID, rings - 1, 'rings') |
| 61 | + |
| 62 | + embed.setDescription(`${user.tag} and ${proposer.user.tag} are now married`) |
| 63 | + .setImage('https://media.giphy.com/media/vTfFCC3rSfKco/giphy.gif') |
| 64 | + .setColor(colors.pink) |
| 65 | + message.channel.send(embed) |
| 66 | + } |
| 67 | + if (reaction.emoji.id === '637573919204966410') { // No emoji |
| 68 | + embed.setTitle(`Sorry **${proposer.user.tag}**, **${user.tag}** declined your proposal.`) |
| 69 | + message.edit(embed) |
| 70 | + } |
| 71 | + }) |
| 72 | + .catch(collected => { |
| 73 | + message.channel.send(`Sorry ${proposer.user.tag}, the person you proposed to didn't respond, try again later.`) |
| 74 | + }); |
| 75 | + }) |
| 76 | +} |
| 77 | + |
| 78 | +exports.conf = { |
| 79 | + enabled: true, |
| 80 | + aliases: ['propose', 'preparetoruinyourlife'], |
| 81 | + guildOnly: true, |
| 82 | + permLevel: 'User' |
| 83 | +} |
| 84 | + |
| 85 | +exports.help = { |
| 86 | + name: 'marry', |
| 87 | + category: 'Fun', |
| 88 | + description: 'Proposes to <member>.', |
| 89 | + usage: 'marry <member>' |
| 90 | +} |
0 commit comments