Advertisement
alipass

كود اكس بي كتابه

May 16th, 2019
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. const mysql = require("mysql"); //npm i mysql
  2. var con = mysql.createConnection({
  3. host: 'localhost',
  4. user: "root",
  5. password: "-----", //باس وورد الما سكل حق
  6. database: 'test'
  7. });
  8.  
  9. con.connect(e => {
  10. if(e) return console.log(e);
  11. console.log(`First SQL is Running`);
  12. });
  13. client.on('message', message =>{
  14. if(message.author.bot) return
  15.  
  16. let xpadd = Math.floor(Math.random() * (30 - 20 + 1));
  17.  
  18. con.query(`SELECT * FROM users_data WHERE userID = '${message.author.id}'
  19. ORDER BY userXP`, (err , rows)=>{
  20. if(err) return console.log(err);
  21.  
  22. if(!rows || !rows[0] || rows.length < 1){
  23. con.query(`INSERT INTO users_data (userID , userXP) VALUES ('${message.author.id}', ${0})`);
  24. console.log(`VALUES add to ${message.author.tag}`);
  25. } else {
  26. con.query(`UPDATE users_data SET userXP = ${Math.floor(rows[0].userXP + xpadd)} WHERE userID = '${message.author.id}'`);
  27. };
  28.  
  29. })
  30.  
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement