Guest User

Untitled

a guest
May 18th, 2018
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const mysql = require("mysql");
  3. const settings = require("./../Constants/settings.json");
  4. const timeout = new Set()
  5.  
  6. var connection = mysql.createConnection({
  7. host: settings.EndPoint,
  8. user:"rem",
  9. password:settings.mysqlpass,
  10. database:"rem"
  11. });
  12.  
  13.  
  14.  
  15. exports.run = (client, message, args, args2, argresult) => {
  16. let amount = argresult;
  17.  
  18. connection.query(`SELECT * FROM users WHERE id = '${message.author.id}'`, (err,rows) => {
  19. if(err) throw(err);
  20. if (rows.length < 1){
  21. connection.query(`INSERT INTO users (id, bal, xp) VALUES ('${message.author.id}', ${randomCash()}, ${randomXP()})`);
  22. }else{
  23.  
  24. var bal = parseInt(rows[0].bal)
  25. var bank = parseInt(rows[0].bank)
  26. if (!amount){
  27. var embed = new Discord.RichEmbed()
  28. .setColor(0xFF0000)
  29. .setDescription(`${message.author} Please give me a valid amount (d!withdrawal 100)`)
  30. message.channel.send(embed)
  31. }else if (parseInt(amount) < 100){
  32. var embed = new Discord.RichEmbed()
  33. .setColor(0xFF0000)
  34. .setDescription(`Sorry ${message.author} You cannot withdrawal less than $100`)
  35. message.channel.send(embed)
  36. }else if (parseInt(amount) > bank){
  37. var embed = new Discord.RichEmbed()
  38. .setColor(0xFF0000)
  39. .setDescription(`Sorry ${message.author} You do not have enough money to withdrawal $${amount}, You only have $${bal}`)
  40. message.channel.send(embed)
  41. }else if (bank === 0){
  42. var embed = new Discord.RichEmbed()
  43. .setColor(0xFF0000)
  44. .setDescription(`Sorry ${message.author} You have nothing to withdrawal!`)
  45. message.channel.send(embed)
  46. }else if (amount === "ALL" || amount === "All" || amount === "all"){
  47.  
  48. if (parseInt(amount) < 100){
  49. var embed = new Discord.RichEmbed()
  50. .setColor(0xFF0000)
  51. .setDescription(`Sorry ${message.author} You cannot withdrawal less than $100`)
  52. message.channel.send(embed)
  53. }else{
  54. connection.query(`UPDATE users SET bal = ${bal + bank}, bank = ${bank - bank} WHERE id = '${message.author.id}'`);
  55. var embed = new Discord.RichEmbed()
  56. .setColor(0x00FF00)
  57. .setTitle("Money Withdrawn")
  58. .setDescription(`${message.author} You just withdrawn $${bank} into your wallet\n\n You now have $${bank - bank} in your bank and $${bank + bal} cash`)
  59. message.channel.send(embed)
  60. }
  61.  
  62. }else{
  63. if (isNaN(amount)){
  64. var embed = new Discord.RichEmbed()
  65. .setColor(colors.red)
  66. .setDescription(`Please give me a valid positive number. Not a letter or a negative number.`)
  67. message.channel.send(embed)
  68. }else{
  69. connection.query(`UPDATE users SET bal = ${bal + parseInt(amount)}, bank = ${bank - parseInt(amount)} WHERE id = '${message.author.id}'`);
  70. var embed = new Discord.RichEmbed()
  71. .setColor(0x00FF00)
  72. .setTitle("Money Withdrawn")
  73. .setDescription(`${message.author} You just withdrawn $${parseInt(amount)} into your wallet\n\n You now have $${bank - parseInt(amount)} in your bank and $${bal + parseInt(amount)} in your wallet`)
  74. message.channel.send(embed)
  75. }
  76. }
  77. }
  78. });
  79. }
Add Comment
Please, Sign In to add comment