const Discord = require('discord.js'); const botconfig = require("../botconfig.json"); const fs = require("fs"); const money = require("../money.json"); const ms = require("parse-ms"); const workcd = require("../workcd.json"); const mongoose = require("mongoose"); mongoose.connect(botconfig.mongoPass, { useNewUrlParser: true, useUnifiedTopology: true, }); const Data = require("../models/data.js"); module.exports.run = async (bot, message, args) => { let timeout = 60000; let rewardlist = [2, 5, 8, 11, 13, 17, 21, 26, 28, 33, 35, 39, 40, 42, 46, 48, 50, 51, 52, 59, 60, 64, 69, 71, 73, 77, 78, 80, 82, 84, 86, 88, 91, 93, 95, 97, 99]; var reward = rewardlist[Math.floor(Math.random() * rewardlist.length)]; let textlist = ['You work as a Katz developer and give yourself', 'You work as a stripper and scoop up', 'You professionally eat a bowl of cereal and inside the box find', 'You travel to space and an alien gives you', 'You invest in Katz and profit']; var text = textlist[Math.floor(Math.random() * textlist.length)]; let user = message.author; Data.findOne({ userID: user.id }, (err, data) => { if(err) console.log(err); if(!data) { const newData = new Data({ userID: message.author.id, name: bot.users.cache.get(message.author.id).tag, lb: "all", money: reward, bank: 0, daily: Date.now(), }) newData.save().catch(err => console.log(err)); return message.channel.send(`${text} **${reward} coins**!`); } else { if(timeout - (Date.now() - data.daily) > 0) { let time = ms(timeout - (Date.now() - data.daily)); return message.channel.send(`Quit working so hard! You can work again in **${time.seconds} seconds**.`) } else { data.money += reward; data.daily = Date.now(); data.save().catch(err => console.log(err)); return message.channel.send(`${text} **${reward} coins**!`); } } }); } module.exports.help = { name: "work", aliases: ["job", "w"] }