Advertisement
Guest User

Untitled

a guest
Jul 12th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const config = require('../config.json');
  3. const mysql = require('mysql');
  4.  
  5. exports.run = (message, args) => {
  6. const max = 1000;
  7. let rate;
  8.  
  9. const scam = Math.floor(Math.random() * max);
  10.  
  11. if(scam === max) {
  12. rate = 15;
  13. } else if(scam > 990) {
  14. rate = 10;
  15. } else if(scam > 900) {
  16. rate = 3;
  17. } else if(scam > 500) {
  18. rate = 2;
  19. } else if(scam === 777) {
  20. rate = 7;
  21. } else if(scam === 1) {
  22. rate = -3;
  23. } else if(scam === 0) {
  24. rate = -5;
  25. } else if(scam <= 350) {
  26. rate = -2;
  27. } else {
  28. rate = 1.5;
  29. }
  30.  
  31. let e = new Discord.RichEmbed()
  32. .setColor(config.hex)
  33. .setAuthor(message.author.tag)
  34. .setThumbnail(message.author.avatarURL);
  35.  
  36. let con = mysql.createConnection({
  37. host: 'localhost',
  38. user: 'root',
  39. password: '2307',
  40. database: 'wynn'
  41. });
  42.  
  43. let current;
  44.  
  45. con.query(`SELECT * FROM coin WHERE id = ${message.author.id}`, (err, rows) => {
  46. if(err) throw err;
  47.  
  48. // console.log(rows);
  49.  
  50. if(!rows[0]) {
  51. e.setDescription('Silly you can\'t bet without any coins.');
  52. } else {
  53. current = rows[0].coin;
  54. }
  55. });
  56.  
  57. const newCurrent = current + (rate * args[0]) ;
  58.  
  59. if(args.length < 1 || isNaN(args[0]) && args[0].toLowerCase() !== 'all') {
  60. e.setDescription('Oof invalid betting amount dear.');
  61. } else {
  62. e.addField('Your roll:', scam);
  63. if(scam <= 350) {
  64. e.setDescription('Aww darling you lost..');
  65. } else {
  66. e.setDescription("You won!");
  67. }
  68. e.addField('Old balance:' , current);
  69. e.addField('New balance:', newCurrent)
  70. }
  71. // let sql = `UPDATE coin SET coin = ${coin + amount} WHERE id = ${message.author.id}`;
  72. message.channel.send({ embed : e });
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement