Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FIRST PART THAT GETS CALLED WHEN USER CLICKS BUTTON //
- client.on('startData', function (user) {
- console.log("Started getting Data");
- //Useful to know when someone disconnects
- console.log(user);
- var t = false;
- LolApi.Summoner.getByName(user)
- .then(function (summoner) {
- var id = summoner[user].id;
- LolApi.getRecentGames(id)
- .then(function (summoners) {
- var list = summoners[1].fellowPlayers;
- for(i = 0; i < list.length; i++){
- var id = summoners[1].fellowPlayers[i].summonerId;
- console.log("hello " + id);
- data(id, client);
- }
- });
- });
- });
- // LOOPING FUNCTIONS //
- function addMore(name){
- var con = mysql.createConnection({
- host: "sql9.freemysqlhosting.net",
- user: "sql9132819",
- password: "5jt2vZeRmH",
- database: "sql9132819"
- });
- con.query("INSERT INTO League (User) VALUES ('" + name + "')",function(err,rows){
- if(err){
- } else if(!err) {
- try{
- } catch (err) {
- }
- }
- });
- }
- function startAgain(id, client){
- console.log(id);
- LolApi.getRecentGames(id, client)
- .then(function (summoners) {
- var list = summoners[1].fellowPlayers;
- for(i = 0; i < list.length; i++){
- var id = summoners[1].fellowPlayers[i].summonerId;
- console.log("hello " + id);
- data(id, client);
- }
- });
- }
- function data(id, client){
- LolApi.Summoner.getByID(id)
- .then(function (summonert) {
- var name = summonert[id].name;
- console.log(name);
- addMore(name);
- setTimeout(function pop(){
- startAgain(id, client);
- }, 700);
- client.emit("addNew");
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement