gaber-elsayed

Steal Command (JS) (Mongodb)

Apr 19th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. const db = require('../../models/Economy')
  2. const Discord = require('discord.js')
  3.  
  4. module.exports = {
  5. name: "steal",
  6. description: "Steal some credits from a user.",
  7. category: "economy",
  8. usage: "steal <user>",
  9. example: "steal @casey",
  10. aliases: [`rob`],
  11. botPermission: [],
  12. authorPermission: [],
  13. guildOnly: true,
  14. cooldown: "3s",
  15. ownerOnly: false,
  16. run: async (bot, message, args, noPerms) => {
  17.  
  18. var tryrob = message.mentions.users.first() || bot.users.cache.get(args[0])
  19. if (!tryrob || !args[0]) {
  20. return noPerms(bot, message, `Please provide a user.`, `steal <user>`)
  21. }
  22.  
  23. await db.findOne({ userID: message.author.id }, async (err, data) => {
  24. if (err) throw err
  25. if (!data) {
  26. new db({
  27. guildID: message.guild.id,
  28. userID: message.author.id,
  29. money: 0,
  30. workCooldown: 0,
  31. dailyCooldown: 0,
  32. begCooldown: 0,
  33. fishCooldown: 0
  34. }).save()
  35. return message.channel.send(`Looks like you don't have any credits ;-; .`)
  36. } else if (data) {
  37. const coins = Math.floor(Math.random() * data.money) + 1;
  38. await db.findOne({ userID: tryrob.id }, async (err1, data1) => {
  39. if (err1) throw err1
  40. if (!data1) {
  41. if (random() === true) {
  42. new db({
  43. guildID: message.guild.id,
  44. userID: tryrob.id,
  45. money: -coins,
  46. workCooldown: 0,
  47. dailyCooldown: 0,
  48. begCooldown: 0,
  49. fishCooldown: 0
  50. }).save()
  51. data.money += coins
  52. data.save()
  53. return message.channel.send(
  54. new Discord.MessageEmbed()
  55. .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
  56. .setColor("GREEN")
  57. .setDescription(`You just robed ${tryrob}! And you got \`${coins}\` credits.`)
  58. )
  59. } else {
  60. new db({
  61. guildID: message.guild.id,
  62. userID: tryrob.id,
  63. money: coins,
  64. workCooldown: 0,
  65. dailyCooldown: 0,
  66. begCooldown: 0,
  67. fishCooldown: 0
  68. }).save()
  69. data.money -= coins
  70. data.save()
  71. return message.channel.send(
  72. new Discord.MessageEmbed()
  73. .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
  74. .setColor("RED")
  75. .setDescription(`Dammit you got caught robbing ${tryrob}! And you had to pay them \`${coins}\` credits.`)
  76. )
  77. }
  78. } else if (data1) {
  79. if (random() === true) {
  80. data.money += coins
  81. data.save()
  82. data1.money -= coins
  83. data1.save()
  84. return message.channel.send(
  85. new Discord.MessageEmbed()
  86. .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
  87. .setColor("GREEN")
  88. .setDescription(`You just robed ${tryrob}! And you got \`${coins}\` credits.`)
  89. )
  90. } else {
  91. data.money -= coins
  92. data.save()
  93. data1.money += coins
  94. data1.save()
  95. return message.channel.send(
  96. new Discord.MessageEmbed()
  97. .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
  98. .setColor("RED")
  99. .setDescription(`Dammit you got caught robbing ${tryrob}! And you had to pay them \`${coins}\` credits.`)
  100. )
  101. }
  102. }
  103. })
  104. }
  105. })
  106. function random() {
  107. const num = Math.floor(Math.random() * 3)
  108. return num === 1
  109. }
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment