Advertisement
Guest User

Untitled

a guest
May 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js')
  2. const db = require('../util/db.js')
  3. let gems = '💎';
  4. let cash = '<:cash:577826085157208064>';
  5. let digging = '<:shove_dig:578754542309605417>';
  6. let cooldown = '<:cooldown:579496045059375104>';
  7. let denied = '<:denied:578904707691577345>';
  8. module.exports.run = (client, msg, args, db, settings, util, lang) => {
  9.   let sIcon = msg.guild.iconURL;
  10.   let rAmount = Math.floor(Math.random() * 15);
  11.   var responses = [
  12.     'fail',
  13.     'success'
  14.   ]
  15.   let answer = responses[Math.floor(Math.random() * responses.length)];
  16.   db.dig(msg.author.id).then(dig => {
  17.       db.MongoFind("users", { id: msg.author.id }).then(info => {
  18.           let time = new Date().getTime()
  19.           var userEco = info[0].economy;
  20.           if (dig == true && answer == 'success') {
  21.               db.MongoUpdate("users", { id: msg.author.id }, { 'economy.balance': userEco.gems + rAmount });
  22.               db.lastSeen(msg.author.id, 'hourly')
  23.               let dailyembed = new Discord.RichEmbed()
  24.               .setAuthor(`${msg.author.tag}`, msg.author.displayAvatarURL)
  25.               .setDescription(`${digging}| <@${msg.author.id}>, you have found \`${rAmount}\` ${gems} in a dusty mine shaft! \n :white_small_square: Your new balance is: \`${userEco.gems + rAmount}\` ${gems}`)
  26.               .setTimestamp()
  27.               .setColor("#36393f")
  28.               .setFooter(msg.author.id, sIcon)
  29.               return msg.channel.send(dailyembed);
  30.           }
  31.           else if (dig == true && answer == 'fail') {
  32.             db.lastSeen(msg.author.id, 'hourly')
  33.             let failembed = new Discord.RichEmbed()
  34.             .setAuthor(`${msg.author.tag}`, msg.author.displayAvatarURL)
  35.             .setDescription(`${digging}| <@${msg.author.id}>, you didn't find any ${gems}, instead you found a lump of coal.`)
  36.            .setTimestamp()
  37.            .setColor("#36393f")
  38.            .setFooter(msg.author.id, sIcon)
  39.            return msg.channel.send(failembed);
  40.        } else {
  41.              let claimed = new Discord.RichEmbed()
  42.                  .setAuthor(`${msg.author.tag}`, msg.author.displayAvatarURL)
  43.                  .setDescription(`${cooldown}| <@${msg.author.id}>, wait **\`${60 - parseInt(dig)}\`** minute(s) before running this command again!`)
  44.                  .setTimestamp()
  45.                  .setColor("#36393f")
  46.                  .setFooter(msg.author.id, sIcon)
  47.                  return msg.channel.send(claimed);
  48.          }
  49.      });
  50.  });
  51. }
  52.  
  53.  
  54. module.exports.help = {
  55.  name: "dig"
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement