Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. const { CommandStructures, SwitchbladeEmbed, Constants } = require('../../')
  2. const { Command, CommandParameters, CommandRequirements, UserParameter } = CommandStructures
  3.  
  4. const moment = require('moment')
  5.  
  6. const MARRY_VALUE = 30000 // 30.000 Switchcoins needed to marry
  7. const TIME_TO_MARRY = 1000 * 30 // 30 seconds to marry
  8.  
  9. module.exports = class Marry extends Command {
  10. constructor (client) {
  11. super(client)
  12. this.name = 'marry'
  13. this.aliases = ['propose']
  14.  
  15. this.requirements = new CommandRequirements(this, {guildOnly: true, databaseOnly: true})
  16. this.parameters = new CommandParameters(this,
  17. new UserParameter()
  18. )
  19. }
  20.  
  21. async run ({ t, author, channel, guildDocument }, proposed) {
  22. const embed = new SwitchbladeEmbed(author)
  23. const now = Date.now()
  24. moment.locale(guildDocument.language)
  25. if (author === proposed) {
  26. embed.setColor(Constants.ERROR_COLOR)
  27. .setDescription('You can\'t marry yourself')
  28. return channel.send(embed)
  29. }
  30. const authorMarriageStatus = await this.client.modules.social.checkMarriageStatus(author)
  31. if (authorMarriageStatus) {
  32. embed.setColor(Constants.ERROR_COLOR)
  33. .setDescription(`You're already married with ${authorMarriageStatus.spouse.username} since ${moment(authorMarriageStatus.date).format('LLL')}`)
  34. return channel.send(embed)
  35. }
  36. const proposedMarriageStatus = await this.client.modules.social.checkMarriageStatus(proposed)
  37. if (proposedMarriageStatus) {
  38. embed.setColor(Constants.ERROR_COLOR)
  39. .setDescription(`The user you're trying to propose is already married with ${proposedMarriageStatus.spouse.username} since ${moment(proposedMarriageStatus.date).format('LLL')}`)
  40. return channel.send(embed)
  41. }
  42. const balance = await this.client.modules.economy.checkBalance(author)
  43. if (balance < MARRY_VALUE) {
  44. embed.setColor(Constants.ERROR_COLOR)
  45. .setDescription(t('errors:notEnoughMoney'))
  46. return channel.send(embed)
  47. }
  48. embed.setDescription('Dearly beloved, we are gathered here today to witness the union of\n' +
  49. `${author} and ${proposed} in holy matrimony, which is an honorable\n` +
  50. 'estate, that is not to be entered into unadvisedly or lightly, but reverently and\n' +
  51. 'soberly.\n' +
  52. '\n' +
  53. 'Into this estate these two persons present come now to be joined.\n' +
  54. 'If any one can show just cause why they may not be lawfully joined together, let\n' +
  55. 'them speak now or forever hold their peace.\n' +
  56. `Do you, ${proposed.username}, accept ${author.username} as your lawfully wedded spouse?\n` +
  57. '\n' +
  58. '*Times out in 30 seconds*'
  59. )
  60. channel.send(embed).then(async m => {
  61. const filter = (response, user) => response.emoji === Constants.TICK_YES && user === proposed || response.emoji === Constants.TICK_NO && user === proposed
  62. await m.react(Constants.TICK_YES)
  63. await m.react(Constants.TICK_NO)
  64. m.awaitReactions(filter, { max: 1, time: TIME_TO_MARRY, errors: ['time']})
  65. .then(async collected => {
  66. if (collected.first().emoji === Constants.TICK_YES) {
  67. m.delete()
  68. await this.client.modules.social.marry(author, proposed, MARRY_VALUE, now)
  69. embed.setDescription('You have each betrothed yourself to the other in love and compassion, righteousness and truth.\n' +
  70. 'You have taken upon yourselves the responsibilities of a deep and loving friendship.\n' +
  71. 'In the presence of these witnesses and in keeping with tradition, you have spoken the words and preformed rites that unite your lives.\n' +
  72. `${author} and ${proposed}, you are now spouses in the sight of God, and of all people`)
  73. } else if (collected.first().emoji === Constants.TICK_NO) {
  74. m.delete()
  75. embed.setDescription(`We're sorry ${author}, but it seems that ${proposed} just isn't prepared yet to accept you as a spouse...`)
  76. }
  77. }).catch(() => {
  78. m.delete()
  79. embed.setDescription(`It seems that ${proposed} didn't answer on time.`)
  80. })
  81. channel.send(embed)
  82. })
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement