Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const config = require('../config.json');
- const mysql = require('mysql');
- exports.run = (message, args) => {
- const max = 1000;
- let rate;
- const scam = Math.floor(Math.random() * max);
- if(scam === max) {
- rate = 15;
- } else if(scam > 990) {
- rate = 10;
- } else if(scam > 900) {
- rate = 3;
- } else if(scam > 500) {
- rate = 2;
- } else if(scam === 777) {
- rate = 7;
- } else if(scam === 1) {
- rate = -3;
- } else if(scam === 0) {
- rate = -5;
- } else if(scam <= 350) {
- rate = -2;
- } else {
- rate = 1.5;
- }
- let e = new Discord.RichEmbed()
- .setColor(config.hex)
- .setAuthor(message.author.tag)
- .setThumbnail(message.author.avatarURL);
- let con = mysql.createConnection({
- host: 'localhost',
- user: 'root',
- password: '2307',
- database: 'wynn'
- });
- let current;
- con.query(`SELECT * FROM coin WHERE id = ${message.author.id}`, (err, rows) => {
- if(err) throw err;
- // console.log(rows);
- if(!rows[0]) {
- e.setDescription('Silly you can\'t bet without any coins.');
- } else {
- current = rows[0].coin;
- }
- });
- const newCurrent = current + (rate * args[0]) ;
- if(args.length < 1 || isNaN(args[0]) && args[0].toLowerCase() !== 'all') {
- e.setDescription('Oof invalid betting amount dear.');
- } else {
- e.addField('Your roll:', scam);
- if(scam <= 350) {
- e.setDescription('Aww darling you lost..');
- } else {
- e.setDescription("You won!");
- }
- e.addField('Old balance:' , current);
- e.addField('New balance:', newCurrent)
- }
- // let sql = `UPDATE coin SET coin = ${coin + amount} WHERE id = ${message.author.id}`;
- message.channel.send({ embed : e });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement