Advertisement
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 gambletimeout = new Set()
- var connection = mysql.createConnection({
- host: settings.EndPoint,
- user:"rem",
- password:settings.mysqlpass,
- database:"rem"
- });
- function randomCash(){
- var min = 500;
- var max = 1250;
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- function randomXP(){
- var min = 15
- var max = 30
- return Math.floor(Math.random() * (min - max - 1)) + min;
- }
- exports.run = (client, message, args) => {
- if (gambletimeout.has(message.author.id)) return message.reply('You can use this command every 2 seconds');
- let amountBet = args.join(" ");
- var cashBet = parseFloat(amountBet);
- if (!cashBet) return message.reply('Please give me a valid ammount to gamble!')
- connection.query(`SELECT * FROM users WHERE id = '${message.author.id}'`, (err,rows) => {
- if(err) throw(err);
- let usercash = parseFloat(rows[0].bal);
- if (isNaN(cashBet)) return message.reply('Please give me a number, Not a letter');
- if (parseFloat(cashBet) < 5){
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setTitle("GAMBLE TO SMALL")
- .setDescription(`The least you can gamble is $5`)
- message.channel.send(embed);
- }else
- if (parseFloat(cashBet) > usercash){
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setTitle("NOT ENOUGH MONEY")
- .setDescription(`Sorry ${message.author} you do not have enough money to gamble $${cashBet} you only have $${usercash}`)
- message.channel.send(embed);
- }else{
- var result = Math.floor(Math.random() * 100 + 1);
- if (message.author.id === settings.AuthorID){
- result = 100;
- }
- if (result < 75){
- var cashLost = usercash - cashBet;
- var embed = new Discord.RichEmbed()
- .setColor(0xFF0000)
- .setTitle("YOU LOST")
- .setDescription(`Sorry ${message.author} you rolled a ${result} and lost $${cashBet}`)
- connection.query(`UPDATE users SET bal = ${cashLost} WHERE id = '${message.author.id}'`);
- }
- if (result >= 75){
- var cashWon = usercash + (cashBet * 2.5);
- var embed = new Discord.RichEmbed()
- .setColor(0x00FF00)
- .setTitle("YOU WON")
- .setDescription(`${message.author} you rolled a ${result} and won $${cashBet * 2.5}`)
- connection.query(`UPDATE users SET bal = ${cashWon} WHERE id = '${message.author.id}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement