Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const db = require('../../models/Economy')
- const Discord = require('discord.js')
- module.exports = {
- name: "steal",
- description: "Steal some credits from a user.",
- category: "economy",
- usage: "steal <user>",
- example: "steal @casey",
- aliases: [`rob`],
- botPermission: [],
- authorPermission: [],
- guildOnly: true,
- cooldown: "3s",
- ownerOnly: false,
- run: async (bot, message, args, noPerms) => {
- var tryrob = message.mentions.users.first() || bot.users.cache.get(args[0])
- if (!tryrob || !args[0]) {
- return noPerms(bot, message, `Please provide a user.`, `steal <user>`)
- }
- await db.findOne({ userID: message.author.id }, async (err, data) => {
- if (err) throw err
- if (!data) {
- new db({
- guildID: message.guild.id,
- userID: message.author.id,
- money: 0,
- workCooldown: 0,
- dailyCooldown: 0,
- begCooldown: 0,
- fishCooldown: 0
- }).save()
- return message.channel.send(`Looks like you don't have any credits ;-; .`)
- } else if (data) {
- const coins = Math.floor(Math.random() * data.money) + 1;
- await db.findOne({ userID: tryrob.id }, async (err1, data1) => {
- if (err1) throw err1
- if (!data1) {
- if (random() === true) {
- new db({
- guildID: message.guild.id,
- userID: tryrob.id,
- money: -coins,
- workCooldown: 0,
- dailyCooldown: 0,
- begCooldown: 0,
- fishCooldown: 0
- }).save()
- data.money += coins
- data.save()
- return message.channel.send(
- new Discord.MessageEmbed()
- .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
- .setColor("GREEN")
- .setDescription(`You just robed ${tryrob}! And you got \`${coins}\` credits.`)
- )
- } else {
- new db({
- guildID: message.guild.id,
- userID: tryrob.id,
- money: coins,
- workCooldown: 0,
- dailyCooldown: 0,
- begCooldown: 0,
- fishCooldown: 0
- }).save()
- data.money -= coins
- data.save()
- return message.channel.send(
- new Discord.MessageEmbed()
- .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
- .setColor("RED")
- .setDescription(`Dammit you got caught robbing ${tryrob}! And you had to pay them \`${coins}\` credits.`)
- )
- }
- } else if (data1) {
- if (random() === true) {
- data.money += coins
- data.save()
- data1.money -= coins
- data1.save()
- return message.channel.send(
- new Discord.MessageEmbed()
- .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
- .setColor("GREEN")
- .setDescription(`You just robed ${tryrob}! And you got \`${coins}\` credits.`)
- )
- } else {
- data.money -= coins
- data.save()
- data1.money += coins
- data1.save()
- return message.channel.send(
- new Discord.MessageEmbed()
- .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
- .setColor("RED")
- .setDescription(`Dammit you got caught robbing ${tryrob}! And you had to pay them \`${coins}\` credits.`)
- )
- }
- }
- })
- }
- })
- function random() {
- const num = Math.floor(Math.random() * 3)
- return num === 1
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment