Advertisement
Guest User

Yeet

a guest
Nov 10th, 2018
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //pinger
  2. const http = require('http');
  3. const express = require('express');
  4. const app = express();
  5. app.get("/", (request, response) => {
  6.   response.sendStatus(200);
  7. });
  8. app.listen(process.env.PORT);
  9. setInterval(() => {
  10.   http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
  11. }, 60000);
  12. //pings every minute
  13.  
  14.  
  15.  
  16. var discord = require('discord.js');
  17. var roblox = require('roblox-js');
  18. var client = new discord.Client();
  19. var token = "NDc2ODExMTU4NTcwMDA4NjA2.Dk4FHg.DyYkTKOjTz65xk2axuWQ0gw27HA"
  20. client.login(token)
  21.  
  22. roblox.login({username: "LegendNations", password: "legendnationsdiscordbot3536"}).then((success) => {
  23.  
  24. }).catch(() => {console.log("Sorry, it failed.");});
  25.  
  26.  
  27. client.on("ready", () => {
  28.   console.log(`Ready to serve on ${client.guilds.size} servers, for ${client.users.size} users.`);
  29. });
  30.  
  31. client.on('guildMemberAdd', member => {
  32.   let guild = member.guild;
  33.   let user = member.user
  34.   console.log(`${user.tag} joined ${guild}`)
  35. });
  36.  
  37. client.on('guildMemberRemove', member => {
  38.   let guild = member.guild;
  39.   let user = member.user
  40.   console.log(`${user.tag} left ${guild}`)
  41. });
  42.  
  43. var prefix = 'lh!';
  44. var groupId = 3373659;
  45. var maximumRank = 253;
  46.  
  47. function isCommand(command, message){
  48.     var command = command.toLowerCase();
  49.     var content = message.content.toLowerCase();
  50.     return content.startsWith(prefix + command);
  51. }
  52.  
  53. client.on('message', (message) => {
  54.     if (message.author.bot) return; // Dont answer yourself.
  55.     var args = message.content.split(/[ ]+/)
  56.    
  57.     if(isCommand('Promote', message)){
  58.     if(message.member.roles.has("476808713571794964")) {
  59.       var username = args[1]
  60.         if (username){
  61.             message.channel.send(`Checking ROBLOX for ${username}`)
  62.             roblox.getIdFromUsername(username)
  63.             .then(function(id){
  64.                 roblox.getRankInGroup(groupId, id)
  65.                 .then(function(rank){
  66.                     if(maximumRank <= rank){
  67.                         message.channel.send(`${id} is rank ${rank} and not promotable.`)
  68.                     } else {
  69.                         message.channel.send(`${id} is rank ${rank} and promotable.`)
  70.                         roblox.promote(groupId, id)
  71.                         .then(function(roles){
  72.                             message.channel.send(`Promoted from "${roles.oldRole.Name}" to "${roles.newRole.Name}"`)
  73.                         }).catch(function(err){
  74.                             message.channel.send("Failed to promote.")
  75.                         });
  76.                     }
  77.                 }).catch(function(err){
  78.                     message.channel.send("Couldn't get him in the group.")
  79.                 });
  80.             }).catch(function(err){
  81.                 message.channel.send('Sorry, but ${username} doesn\'t exist on ROBLOX.')
  82.             });
  83.         } else {
  84.             message.channel.send("Please enter a username.")
  85.         }
  86.         return;
  87.     }
  88.     }
  89.           if(isCommand('Demote', message)){
  90.     if(message.member.roles.has("476808713571794964")) {
  91.       var username = args[1]
  92.         if (username){
  93.             message.channel.send(`Checking ROBLOX for ${username}`)
  94.             roblox.getIdFromUsername(username)
  95.             .then(function(id){
  96.                 roblox.getRankInGroup(groupId, id)
  97.                 .then(function(rank){
  98.                     if(maximumRank <= rank){
  99.                         message.channel.send(`${id} is rank ${rank} and is not allowed demote.`)
  100.                     } else {
  101.                         message.channel.send(`${id} is rank ${rank} and allowed to demote.`)
  102.                         roblox.changeRank(groupId, id, -1)
  103.                         .then(function(roles){
  104.                             message.channel.send(`Demoted to ${roles.newRole.Name}`)
  105.                         }).catch(function(err){
  106.                             message.channel.send("Failed to demote.")
  107.                         });
  108.                     }
  109.                 }).catch(function(err){
  110.                     message.channel.send("Couldn't get him in the group.")
  111.                 });
  112.             }).catch(function(err){
  113.                 message.channel.send('Sorry, but ${username} doesn\'t exist on ROBLOX.')
  114.             });
  115.         } else {
  116.             message.channel.send("Please enter a username.")
  117.         }
  118.         return;
  119.  
  120.     }  
  121.           }
  122.         if(isCommand('shout', message)){
  123.     if(message.member.roles.has("476808713571794964")) {
  124.       var username = args.join(" ").slice(6);
  125.  roblox.shout(groupId,username)
  126. message.channel.send("Shout completed.")
  127.       }
  128.         return;
  129.     }
  130.      
  131. }
  132.            
  133.                        
  134.                  
  135.               );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement