Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { CommandStructures, SwitchbladeEmbed, Constants } = require('../../')
- const { Command, CommandParameters, CommandRequirements, UserParameter } = CommandStructures
- const moment = require('moment')
- const MARRY_VALUE = 30000 // 30.000 Switchcoins needed to marry
- const TIME_TO_MARRY = 1000 * 30 // 30 seconds to marry
- module.exports = class Marry extends Command {
- constructor (client) {
- super(client)
- this.name = 'marry'
- this.aliases = ['propose']
- this.requirements = new CommandRequirements(this, {guildOnly: true, databaseOnly: true})
- this.parameters = new CommandParameters(this,
- new UserParameter()
- )
- }
- async run ({ t, author, channel, guildDocument }, proposed) {
- const embed = new SwitchbladeEmbed(author)
- const now = Date.now()
- moment.locale(guildDocument.language)
- if (author === proposed) {
- embed.setColor(Constants.ERROR_COLOR)
- .setDescription('You can\'t marry yourself')
- return channel.send(embed)
- }
- const authorMarriageStatus = await this.client.modules.social.checkMarriageStatus(author)
- if (authorMarriageStatus) {
- embed.setColor(Constants.ERROR_COLOR)
- .setDescription(`You're already married with ${authorMarriageStatus.spouse.username} since ${moment(authorMarriageStatus.date).format('LLL')}`)
- return channel.send(embed)
- }
- const proposedMarriageStatus = await this.client.modules.social.checkMarriageStatus(proposed)
- if (proposedMarriageStatus) {
- embed.setColor(Constants.ERROR_COLOR)
- .setDescription(`The user you're trying to propose is already married with ${proposedMarriageStatus.spouse.username} since ${moment(proposedMarriageStatus.date).format('LLL')}`)
- return channel.send(embed)
- }
- const balance = await this.client.modules.economy.checkBalance(author)
- if (balance < MARRY_VALUE) {
- embed.setColor(Constants.ERROR_COLOR)
- .setDescription(t('errors:notEnoughMoney'))
- return channel.send(embed)
- }
- embed.setDescription('Dearly beloved, we are gathered here today to witness the union of\n' +
- `${author} and ${proposed} in holy matrimony, which is an honorable\n` +
- 'estate, that is not to be entered into unadvisedly or lightly, but reverently and\n' +
- 'soberly.\n' +
- '\n' +
- 'Into this estate these two persons present come now to be joined.\n' +
- 'If any one can show just cause why they may not be lawfully joined together, let\n' +
- 'them speak now or forever hold their peace.\n' +
- `Do you, ${proposed.username}, accept ${author.username} as your lawfully wedded spouse?\n` +
- '\n' +
- '*Times out in 30 seconds*'
- )
- channel.send(embed).then(async m => {
- const filter = (response, user) => response.emoji === Constants.TICK_YES && user === proposed || response.emoji === Constants.TICK_NO && user === proposed
- await m.react(Constants.TICK_YES)
- await m.react(Constants.TICK_NO)
- m.awaitReactions(filter, { max: 1, time: TIME_TO_MARRY, errors: ['time']})
- .then(async collected => {
- if (collected.first().emoji === Constants.TICK_YES) {
- m.delete()
- await this.client.modules.social.marry(author, proposed, MARRY_VALUE, now)
- embed.setDescription('You have each betrothed yourself to the other in love and compassion, righteousness and truth.\n' +
- 'You have taken upon yourselves the responsibilities of a deep and loving friendship.\n' +
- 'In the presence of these witnesses and in keeping with tradition, you have spoken the words and preformed rites that unite your lives.\n' +
- `${author} and ${proposed}, you are now spouses in the sight of God, and of all people`)
- } else if (collected.first().emoji === Constants.TICK_NO) {
- m.delete()
- embed.setDescription(`We're sorry ${author}, but it seems that ${proposed} just isn't prepared yet to accept you as a spouse...`)
- }
- }).catch(() => {
- m.delete()
- embed.setDescription(`It seems that ${proposed} didn't answer on time.`)
- })
- channel.send(embed)
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement