Advertisement
Guest User

some code

a guest
Jan 28th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. roblox.login({username: "F_ruits", password: "PASSWORD_HERE"}).then((success) => {
  2.  
  3. }).catch(() => {console.log("Failed to login.");
  4.  
  5. });
  6.  
  7. function isAdmin(message){
  8.     if(
  9.         hasRole(message.member,"Chairwoman") ||
  10.         hasRole(message.member,"Chairwoman") ||
  11.         hasRole(message.member,"President") ||
  12.         hasRole(message.member,"Vice President") ||
  13.         hasRole(message.member,"Corporate Team") ||
  14.         hasRole(message.member,"Advisor") ||
  15.     hasRole(message.member,"Manager") ||
  16.     hasRole(message.member,"Advisor")
  17.         ){
  18.       var discord = require('discord.js');
  19.       var roblox = require('roblox-js');
  20.       var client = new discord.Client();
  21.       var token = "TOKEN_HERE"
  22.       client.login(token)
  23.  
  24.       //
  25.  
  26.       client.on("ready", () => {
  27.         client.user.setGame(`ranking users!`);
  28.         console.log(`Ready to serve on ${client.guilds.size} servers, for ${client.users.size} users.`);
  29.  
  30.       //
  31.  
  32.  
  33.       var prefix = '!!';
  34.       var groupId = 3794284;
  35.       var maximumRank = 255;
  36.  
  37.       function isCommand(command, message){
  38.         var command = command.toLowerCase();
  39.         var content = message.content.toLowerCase();
  40.         return content.startsWith(prefix + command);
  41.       }
  42.  
  43.       client.on('message', (message) => {
  44.         if (message.author.bot) return; // Dont answer yourself.
  45.           var args = message.content.split(/[ ]+/)
  46.  
  47.           if(isCommand('Promote', message)){
  48.             var username = args[1]
  49.             if (username){
  50.                 message.channel.send(`Checking ROBLOX for ${username}`)
  51.                 roblox.getIdFromUsername(username)
  52.                 .then(function(id){
  53.                     roblox.getRankInGroup(groupId, id)
  54.                     .then(function(rank){
  55.                         if(maximumRank <= rank){
  56.                             message.channel.send(`${id} is rank ${rank} and not promotable.`)
  57.                         } else {
  58.                             message.channel.send(`${id} is rank ${rank} and promotable.`)
  59.                             roblox.promote(groupId, id)
  60.                             .then(function(roles){
  61.                                 message.channel.send(`Promoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
  62.                             }).catch(function(err){
  63.                                 message.channel.send("Failed to promote.")
  64.                             });
  65.                         }
  66.                     }).catch(function(err){
  67.                         message.channel.send("Couldn't get him in the group.")
  68.                     });
  69.                 }).catch(function(err){
  70.                     message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
  71.                 });
  72.             } else {
  73.                 message.channel.send("Please enter a username.")
  74.             }
  75.             return;
  76.  
  77.          }
  78.          function pluck(array){
  79.          return array.map(function(item) { return item['name']; })
  80.      }
  81.  
  82.      function hasRole(members, role){
  83.          if(pluck(members.roles).includes(role)){
  84.              return true;
  85.          } else {
  86.              return false;
  87.          }
  88.      }
  89.  
  90.         return true;
  91.     } else {
  92.         return false;
  93.     }
  94. }
  95. client.on('message', (message) => {
  96.  
  97. if (isAdmin(message)){
  98. console.log('Is an admin!')
  99. }
  100.  
  101. })
  102.  
  103. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement