Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mysql = require("mysql"); //npm i mysql
- var con = mysql.createConnection({
- host: 'localhost',
- user: "root",
- password: "-----", //باس وورد الما سكل حق
- database: 'test'
- });
- con.connect(e => {
- if(e) return console.log(e);
- console.log(`First SQL is Running`);
- });
- client.on('message', message =>{
- if(message.author.bot) return
- let xpadd = Math.floor(Math.random() * (30 - 20 + 1));
- con.query(`SELECT * FROM users_data WHERE userID = '${message.author.id}'
- ORDER BY userXP`, (err , rows)=>{
- if(err) return console.log(err);
- if(!rows || !rows[0] || rows.length < 1){
- con.query(`INSERT INTO users_data (userID , userXP) VALUES ('${message.author.id}', ${0})`);
- console.log(`VALUES add to ${message.author.tag}`);
- } else {
- con.query(`UPDATE users_data SET userXP = ${Math.floor(rows[0].userXP + xpadd)} WHERE userID = '${message.author.id}'`);
- };
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement