Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const balanceEnough = function(amt) {
  2.     return new Promise(function(resolve,reject) {
  3.         bot.chat('/bal');
  4.         setInterval(() => {
  5.             if(returned){
  6.                 if(amt === "all") {
  7.                     resolve(currentBalance);
  8.                     return;
  9.                 }
  10.                 if(currentBalance > amt) {
  11.                     returned = false;
  12.                     resolve(true)
  13.                     return;
  14.                 } else {
  15.                     returned = false;
  16.                     resolve(false)
  17.                     return;
  18.                 }
  19.             }
  20.         })
  21.  
  22.         //reject(new Error('lol wut'))
  23.     })
  24. }
  25.                    
  26. if(m[0] === '!withdraw') {
  27.     if(m.length) {
  28.         if(isNaN(m[1])){
  29.             if(m[1] === "all" || m[1] === "all."){
  30.                 let date_time = dtime();
  31.                 balanceEnough("all").then(function(amt){
  32.                     addHist(username, date_time[1], date_time[0], amt, "withdraw")
  33.                     setTimeout(() => {
  34.                         bot.chat('/pay ' + username + ' ' + amt)
  35.                     },500)
  36.                 })
  37.           return;
  38.          } else {
  39.             bot.chat('/msg ' + username + " You did not provide a valid number.")
  40.          }
  41.  
  42. if(msg.includes('<!> Balance: $')){
  43.     if(!msg.includes("*") && !msg.includes("-") && !msg.includes('[')){
  44.         msg = msg.replace('<!> Balance: $', '').replace(/,/g, '');
  45.         currentBalance = parseInt(msg);
  46.         returned = true;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement