Advertisement
Guest User

bot

a guest
Jun 24th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('message', message => {
  2.     var patt1 = /the game/i;
  3.     //var patt2 = /^(>multi)/i;
  4.     if (LOCALHOST == 0 && patt1.test(message.content) && (Date.now() - dernierperdu) > 3600000 && dernierperdant != message.author) {
  5.         dernierperdu = Date.now();
  6.         dernierperdant = message.author;
  7.         message.channel.send('I just lost.');
  8.     }
  9.     else if (LOCALHOST == 0 && message.content.substring(0, 9) == '!devpolls') {
  10.         var membre = guilde.member(message.author.id).roles.keyArray();    
  11.         var roles = [], ml = membre.length, ok = 0;
  12.         for (var i = 0; i < ml; i++) {
  13.             if (membre[i] == '455425290055843840') { ok = 1; }
  14.             else { roles.push(membre[i]); }
  15.         }
  16.         if (ok == 0) { roles.push('455425290055843840') }
  17.         guilde.member(message.author.id).setRoles(roles);
  18.         if (ok == 1) { message.channel.send('You do not have the role anymore.'); }
  19.         else { message.channel.send('You now have the role. Thank you for caring about Worldwide Combos!'); }
  20.     }
  21.     else if (LOCALHOST == 0 && message.content.substring(0, 5) == '!help') {
  22.         var texte = "```PROFILE CARDS: !profile <username>\nSYNCHRONIZE YOUR ACCOUNT: !sync\n";
  23.         texte += "SOCIAL MEDIA: !facebook !twitter !youtube\n";
  24.         texte += "OTHER: !history !upcoming !online !members\nHELP: !help\n";
  25.         texte += "DEV SUBSCRIPTION: !devpolls```";
  26.         message.channel.send(texte);
  27.     }
  28.     else if (LOCALHOST == 0 && message.content.substring(0, 8) == '!history') {
  29.         message.channel.send('Previous updates\' changelog: https://www.worldwide-combos.com/wiki/history');
  30.     }
  31.     else if (LOCALHOST == 0 && message.content.substring(0, 9) == '!upcoming') {
  32.         message.channel.send('List of upcoming features: https://www.worldwide-combos.com/wiki/upcoming');
  33.     }
  34.     else if (LOCALHOST == 0 && message.content.substring(0, 7) == '!online') {
  35.         connection.query('SELECT pseudo, pays FROM membres WHERE derniereconnexion > DATE_SUB(NOW(), INTERVAL 5 MINUTE) ORDER BY pseudo', function (error, liste, fields) {
  36.             if (liste.length == 0) { message.channel.send('Nobody is currently online.'); }
  37.             else {
  38.                 var l = 'Current online members: ';
  39.                 for (var i = 0; i < liste.length-1; i++) {
  40.                     l += ':flag_'+cp[liste[i]['pays']]+': ' + liste[i]['pseudo'] + ', ';
  41.                 }
  42.                 l += ':flag_'+cp[liste[liste.length-1]['pays']]+': ' + liste[liste.length-1]['pseudo'] + '.';
  43.                 message.channel.send(l);
  44.             }
  45.         });
  46.     }
  47.     else if (LOCALHOST == 0 && message.content.substring(0, 8) == '!members') {
  48.         connection.query('SELECT COUNT(*) AS nb FROM membres WHERE typemembre = 1 OR typemembre = 2', function (error, nombre, fields) {
  49.             var texte = "```Members with a validated account: "+nombre[0]['nb']+"\n";
  50.             texte += "Members on this Discord server: "+guilde.memberCount+"```";
  51.             message.channel.send(texte);
  52.         });
  53.     }
  54.     else if (LOCALHOST == 0 && message.content.substring(0, 8) == '!profile') {
  55.         var pseudo = message.content.substring(9, message.content.length);
  56.         connection.query('SELECT * FROM membres WHERE typemembre >= 0 AND pseudo = ?', [pseudo], function (error, verif, fields) {
  57.             if (verif.length == 1) {
  58.                 var infos = verif[0];
  59.                 data = new Discord.RichEmbed();
  60.                 data.setColor('GREY');
  61.                 data.setTitle(':flag_'+cp[infos['pays']]+': **'+infos['pseudo']+'**');
  62.                 var desc1 = '', desc2 = '', desc = '';
  63.                 if ((infos["prenom_afficher"] == 1 && infos["prenom"] != "") || (infos["nom_afficher"] == 1 && infos["nom"] != "")) { desc1 += '**Name**\n'; }
  64.                 if (infos["prenom_afficher"] == 1 && infos["prenom"] != "") { desc1 += infos["prenom"] + ' '; }
  65.                 if (infos["nom_afficher"] == 1 && infos["nom"] != "") { desc1 += infos["nom"] + '\n\n'; }
  66.                 if (infos["sexe_afficher"] == 1) { desc1 += '**Gender**\n';  
  67.                     if (infos["sexe"] == 0) { desc1 += 'male\n\n' }
  68.                     else if (infos["sexe"] == 1) { desc1 += 'female\n\n'; }
  69.                     else if (infos["sexe"] == 2) { desc1 += 'other\n\n'; }
  70.                 }
  71.                 desc1 += '**Registration date**\n' + infos["dateinscription"].toString().substring(0, 24) + '\n\n';
  72.                 desc1 += '**Last login**\n' + infos["derniereconnexion"].toString().substring(0, 24) + '\n\n';
  73.                 if (infos["twitch"] != "") { desc1 += '**Twitch channel**\nhttps://twitch.tv/' + infos["twitch"] + '\n\n'; }
  74.                 connection.query('SELECT 1+COUNT(*) AS cl FROM membres WHERE elo1 >= ? AND typemembre < 3 AND typemembre > 0 AND elo1 != 1000', [infos["elo1"]+0.01], function (error, elo1, fields) {
  75.                     connection.query('SELECT 1+COUNT(*) AS cl FROM membres WHERE elo2 >= ? AND typemembre < 3 AND typemembre > 0 AND elo2 != 1000', [infos["elo2"]+0.01], function (error, elo2, fields) {
  76.                         connection.query('SELECT 1+COUNT(*) AS cl FROM membres WHERE sprint > 0 AND sprint <= ? AND typemembre < 3 AND typemembre > 0', [infos["sprint"]-0.00001], function (error, sp40, fields) {
  77.                             connection.query('SELECT 1+COUNT(*) AS cl FROM membres WHERE tournoi > ? AND typemembre < 3 AND typemembre > 0', [infos["tournoi"]+0.00001], function (error, tournoi, fields) {
  78.                                 connection.query('SELECT 1+COUNT(*) AS cl FROM membres WHERE survivor > ? AND typemembre < 3 AND typemembre > 0', [infos["survivor"]+0.00001], function (error, survivor, fields) {
  79.                                     desc2 += '**Tournament points**\n';
  80.                                     if (infos["tournoi"] > 0) { desc2 += infos["tournoi"] + ' (rank: '+tournoi[0]['cl']+')'; } else { desc2 += '0' }  
  81.                                     desc2 += '\n\n**Multiplayer rating**\n';  
  82.                                     if (infos["elo2"] != 1000) { desc2 += infos["elo2"] + ' (rank: '+elo2[0]['cl']+')'; } else { desc2 += '1000'; }  
  83.                                     desc2 += '\n\n**Ghostbuster rating**\n';  
  84.                                     if (infos["elo1"] != 1000) { desc2 += infos["elo1"] + ' (rank: '+elo1[0]['cl']+')'; } else { desc2 += '1000'; }  
  85.        
  86.                                     var ms = Math.floor(parseFloat(infos["sprint"])/60000);
  87.                                     var ss = parseFloat(infos["sprint"])-60000*Math.floor(parseFloat(infos["sprint"])/60000);
  88.                                     if (ss < 10000) { var stc = ms + ":0" + ss/1000; }
  89.                                     else { var stc = ms + ":" + ss/1000; }
  90.        
  91.                                     desc2 += '\n\n**Sprint time**\n';
  92.                                     if (infos["sprint"] > 0) { desc2 += stc + ' (rank: '+sp40[0]['cl']+')'; } else { desc2 += 'none'; }
  93.                                     desc2 += '\n\n**';
  94.        
  95.                                     var ms2 = Math.floor(parseFloat(infos["survivor"])/60000);
  96.                                     var ss2 = parseFloat(infos["survivor"])-60000*Math.floor(parseFloat(infos["survivor"])/60000);
  97.                                     if (ms2 > 4) {
  98.                                         if (ss2 < 10000) { var stc2 = (ms2-4) + ":0" + ss2/1000; }
  99.                                         else { var stc2 = (ms2-4) + ":" + ss2/1000; }
  100.                                     }
  101.                                     else {
  102.                                         if (ss2 < 10000) { var stc2 = ms2 + ":0" + ss2/1000; }
  103.                                         else { var stc2 = ms2 + ":" + ss2/1000; }
  104.                                     }
  105.        
  106.                                     if (infos["survivor"] > 240000) { desc2 += 'Elite Survivor time'; } else { desc2 += 'Survivor time'; }
  107.                                     desc2 += '**\n';
  108.                                     if (infos["survivor"] > 0) { desc2 += stc2 + ' (rank: '+survivor[0]['cl']+')';  } else { desc2 += 'none'; }
  109.                                     data.addField('Information', desc1, true);
  110.                                     data.addField('Performances', desc2, true);
  111.                                     var pseudoCorrige = '', lp = infos['pseudo'].length;
  112.                                     for (var i = 0; i < lp; i++) {
  113.                                         if (infos['pseudo'].substring(i, i+1) == ' ') { pseudoCorrige += '%20'; }
  114.                                         else { pseudoCorrige += infos['pseudo'].substring(i, i+1); }
  115.                                     }
  116.                                     desc += 'Profile link: https://www.worldwide-combos.com/profile?p='+pseudoCorrige+'\n\n';
  117.                                     data.setDescription(desc);
  118.                                     message.channel.send('', data);                                    
  119.                                 });
  120.                             });
  121.                         });
  122.                     });
  123.                 });
  124.             }
  125.         });
  126.        
  127.     }
  128.     else if (LOCALHOST == 0 && message.content.substring(0, 9) == '!facebook') {
  129.         message.channel.send('https://www.facebook.com/worldwidecombos/');
  130.     }
  131.     else if (LOCALHOST == 0 && message.content.substring(0, 8) == '!twitter') {
  132.         message.channel.send('https://www.twitter.com/worldwidecombos/');
  133.     }
  134.     else if (LOCALHOST == 0 && message.content.substring(0, 8) == '!youtube') {
  135.         message.channel.send('https://www.youtube.com/channel/UCxSrPJKU5gOMvinEUWWm1Ww');
  136.     }
  137.     else if (LOCALHOST == 0 && message.content.substring(0, 5) == '!sync') {
  138.         /* ...*/
  139.     }
  140.  
  141. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement