Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const mysql = require("mysql");
- const settings = require("./../Constants/settings.json");
- const timeout = new Set()
- var connection = mysql.createConnection({
- host: settings.EndPoint,
- user:"rem",
- password:settings.mysqlpass,
- database:"rem"
- });
- exports.run = (client, message, args, args2, argresult) => {
- let amount = argresult;
- connection.query(`SELECT * FROM users WHERE id = '${message.author.id}'`, (err,rows) => {
- if(err) throw(err);
- if (rows.length < 1){
- connection.query(`INSERT INTO users (id, bal, xp) VALUES ('${message.author.id}', ${randomCash()}, ${randomXP()})`);
- }else{
- var bal = parseInt(rows[0].bal)
- var bank = parseInt(rows[0].bank)
- if (!amount){
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setDescription(`${message.author} Please give me a valid amount (d!withdrawal 100)`)
- message.channel.send(embed)
- }else if (parseInt(amount) < 100){
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setDescription(`Sorry ${message.author} You cannot withdrawal less than $100`)
- message.channel.send(embed)
- }else if (parseInt(amount) > bank){
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setDescription(`Sorry ${message.author} You do not have enough money to withdrawal $${amount}, You only have $${bal}`)
- message.channel.send(embed)
- }else if (bank === 0){
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setDescription(`Sorry ${message.author} You have nothing to withdrawal!`)
- message.channel.send(embed)
- }else if (amount === "ALL" || amount === "All" || amount === "all"){
- if (parseInt(amount) < 100){
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setDescription(`Sorry ${message.author} You cannot withdrawal less than $100`)
- message.channel.send(embed)
- }else{
- connection.query(`UPDATE users SET bal = ${bal + bank}, bank = ${bank - bank} WHERE id = '${message.author.id}'`);
- var embed = new Discord.RichEmbed()
- .setColor(0x00FF00)
- .setTitle("Money Withdrawn")
- .setDescription(`${message.author} You just withdrawn $${bank} into your wallet\n\n You now have $${bank - bank} in your bank and $${bank + bal} cash`)
- message.channel.send(embed)
- }
- }else{
- if (isNaN(amount)){
- var embed = new Discord.RichEmbed()
- .setColor(colors.red)
- .setDescription(`Please give me a valid positive number. Not a letter or a negative number.`)
- message.channel.send(embed)
- }else{
- connection.query(`UPDATE users SET bal = ${bal + parseInt(amount)}, bank = ${bank - parseInt(amount)} WHERE id = '${message.author.id}'`);
- var embed = new Discord.RichEmbed()
- .setColor(0x00FF00)
- .setTitle("Money Withdrawn")
- .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`)
- message.channel.send(embed)
- }
- }
- }
- });
- }
Add Comment
Please, Sign In to add comment