Advertisement
SadRIP322

coins code

Mar 21st, 2021
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('message', async message => {
  2.     const db = require('quick.db')
  3.     let user = message.mentions.users.first() || message.author;
  4.     let author = message.author;
  5.     let coins = db.get(`coins_${user.id}`);
  6.     const args = message.content.split(' ');
  7.     const balance = args[2];
  8.     const daily = Math.floor(Math.random() * 3000) + 1;
  9.     const ms = require("ms")
  10.     if (!coins) {
  11.         db.set(`coins_${user.id}`, '50');
  12.     }
  13.  
  14.     if (message.content.startsWith(prefix + "coins")) {
  15.         if (args[2]) {
  16.             if (user.bot) return message.channel.send(`**:interrobang: | ${message.author.username}, I can\'t find' ${message.content.split(' ')[1]}!**`);
  17.         }
  18.         if (!args[2]) {
  19.             if (user.bot) return message.channel.send(`**Bots dosn\'t have coins**`);
  20.             message.channel.send(`**${user.username}, balance is **\`${coins}\``);
  21.         }
  22.     } else {
  23.         if (message.content.startsWith(prefix + "pay")) {
  24.  
  25.             if (!coins) {
  26.                 db.set(`coins_${user.id}`, '50');
  27.             }
  28.             if (isNaN(args[2])) return message.channel.send(`**:interrobang: | ${message.author.username}, type the coins you need to transfer!**`);
  29.             if (user.id === message.author.id) return message.channel.send('**You can\'t transfer coins to your self**');
  30.             if (coins < balance) return message.channel.send(`**:thinking: | ${message.author.username}, Your balance is not enough for that!**`);
  31.             let one = Math.floor(Math.random() * 9) + 1;
  32.             let two = Math.floor(Math.random() * 9) + 1;
  33.             let three = Math.floor(Math.random() * 9) + 1;
  34.             let four = Math.floor(Math.random() * 9) + 1;
  35.             let verfyNum = `${one}${two}${three}${four}`;
  36.  
  37.             message.channel.send(`**:heavy_dollar_sign:| please type this \`${verfyNum}\`**`).then(msg => {
  38.                 message.channel.awaitMessages(msg => msg.author.id === message.author.id, { max: 1, time: 10000 }).then(c => {
  39.                     if (c.first().content === verfyNum) {
  40.                         msg.delete();
  41.                         message.channel.send(`**:moneybag: | ${message.author.username}, has transferred \`${balance}\` to ${user}**`);
  42.                         db.set(`coins_${author.id}`, coins - balance);
  43.                         db.set(`coins_${user.id}`, coins - (-balance))
  44.                     } else if (c.first().content !== verfyNum) {
  45.                         msg.delete();
  46.                     }
  47.                 });
  48.             });
  49.         } else {
  50.             if (message.content.startsWith(prefix + "daily")) {
  51.                 let timeout = 8.64e+7;
  52.                 let dailyTime = await db.fetch(`dailyTime_${author.id}`);
  53.                 if (dailyTime === null) dailyTime = 0;
  54.                 if (dailyTime !== null && timeout - (Date.now() - dailyTime) > 0) {
  55.                     let time = timeout - (Date.now() - dailyTime)
  56.                     let timeh = ms(time, { long: true });
  57.                     message.channel.send(`**Please Try Again After :** \`${timeh}\``)
  58.                 } else {
  59.                     await db.set(`dailyTime_${author.id}`, Date.now());
  60.                     message.channel.send(`**You\'ve claimed\`${daily}\` for today**`);
  61.                     db.set(`coins_${user.id}`, coins - (-daily))
  62.                 }
  63.             }
  64.         }
  65.     }
  66. });
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement