Skip to content

Commit

Permalink
Marriage system base
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilot committed Feb 22, 2020
1 parent ac8a18b commit 6301b9f
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 1 deletion.
34 changes: 34 additions & 0 deletions commands/divorce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
exports.run = async (client, message, args) => {
client.life.ensure(message.author.id, {
member: message.author.id,
spouse: 0,
job: 0
})

const spouse = client.life.get(message.author.id, 'spouse')
if (spouse === 0) return message.channel.send('You need to have a spouse before you can divorce them.')

if (args[0] === 'confirm') {
message.channel.send('You divorced your partner.')
client.life.set(message.author.id, 0, 'spouse')
client.life.set(spouse, 0, 'spouse')
}

else {
message.channel.send('You are about to divorce your partner. Type ;;divorce confirm to confirm this action.')
}
}

exports.conf = {
enabled: true,
aliases: ['div', 'fixyourlife'],
guildOnly: true,
permLevel: 'User'
}

exports.help = {
name: 'divorce',
category: 'Fun',
description: 'Divorces your spouse.',
usage: 'divorce'
}
3 changes: 2 additions & 1 deletion commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ exports.run = async (client, message, args, level) => { // eslint-disable-line n
try {
const member = message.mentions.members.first()
let user = ''
if (member) user = message.mentions.members.first()
if (member) user = message.mentions.members.first().user
if (user.bot === true) return message.channel.send('Now why would you want to do that?')
if (!member) user = message.author

client.life.ensure(user.id, {
Expand Down
90 changes: 90 additions & 0 deletions commands/marry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
const Discord = require('discord.js')
const colors = require('../lib/colors.json')

exports.run = async (client, message, args) => {
const user = message.mentions.users.first() || client.users.get(args[0])
if (!user) return message.channel.send('You must mention someone or give their ID!')
if (user.bot === true) return message.channel.send('Don\'t marry bots. They have no feelings... trust me...')
if (user === message.author || message.author.id === user.id) return message.channel.send('It really do be like that sometimes...')

let proposerID = message.author.id
let proposerName = message.author.username

client.life.ensure(user.id, {
member: user.id,
spouse: 0,
job: 0
})

client.life.ensure(message.author.id, {
member: message.author.id,
spouse: 0,
job: 0
})

client.inventory.ensure(message.author.id, {
member: message.author.id,
rings: 0,
petfood: 0,
seeds: 0,
})

const rings = client.inventory.get(message.author.id, 'rings')
const spouse = client.life.get(message.author.id, 'spouse')
const uSpouse = client.life.get(user.id, 'spouse')

if (rings === 0) return message.channel.send('You do not have a wedding ring. Buy one in the shop.')
if (spouse !== 0) return message.channel.send('You cannot have more than one spouse.')
if (uSpouse !== 0) return message.channel.send(`${user.tag} already has a spouse.`)

let embed = new Discord.RichEmbed()
.setDescription(`**${user.tag}**, **${message.author.tag}** is asking for your hand in marriage, would you like to accept?`)

const noEmoji = message.client.emojis.get('637573919204966410')
message.channel.send(embed).then(message => {
message.react('✅').then(() => message.react(noEmoji));

const filter = (reaction, sent) => {
return ['✅', noEmoji].includes(reaction.emoji.name) && sent.id === user.id;
};

const proposer = message.guild.members.get("id", proposerID)

message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first()

if (reaction.emoji.name === '✅') {
client.life.set(proposerID, user.id, 'spouse')
client.life.set(user.id, proposerID, 'spouse')
client.inventory.set(proposerID, rings - 1, 'rings')

embed.setDescription(`${user.tag} and ${proposer.user.tag} are now married`)
.setImage('https://media.giphy.com/media/vTfFCC3rSfKco/giphy.gif')
.setColor(colors.pink)
message.channel.send(embed)
}
if (reaction.emoji.id === '637573919204966410') { // No emoji
embed.setTitle(`Sorry **${proposer.user.tag}**, **${user.tag}** declined your proposal.`)
message.edit(embed)
}
})
.catch(collected => {
message.channel.send(`Sorry ${proposer.user.tag}, the person you proposed to didn't respond, try again later.`)
});
})
}

exports.conf = {
enabled: true,
aliases: ['propose', 'preparetoruinyourlife'],
guildOnly: true,
permLevel: 'User'
}

exports.help = {
name: 'marry',
category: 'Fun',
description: 'Proposes to <member>.',
usage: 'marry <member>'
}
1 change: 1 addition & 0 deletions lib/colors.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"blue": "#3498DB",
"teal": "#4699AA",
"purple": "#995BBD",
"pink": "#F784D9",
"default": "#995BBD"
}

0 comments on commit 6301b9f

Please sign in to comment.