Advertisement
Guest User

ForJordan

a guest
Oct 7th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var discord = require('discord.js');
  2. var roblox = require('roblox-js');
  3. var client = new discord.Client();
  4. var token = "NDk4NjQ3NTY5OTkyMjUzNDYw.DpwyhA.p6fAeXVykceMIFYfKQf0TWVC74Y"
  5. client.login(token)
  6.  
  7. roblox.login({username: "SC_Rank", password: "JordanSC03"}).then((success) => {
  8.  
  9. }).catch(() => {console.log("Sorry, could not log into SC_Rank.");});
  10.  
  11.  
  12. client.on("ready", () => {
  13.   client.user.setActivity(`Smile Construction`);
  14.   console.log("Thanks for using TigerBots!")
  15. });
  16.  
  17. var prefix = '!';
  18.  
  19. function isCommand(command, message){
  20.     var command = command.toLowerCase();
  21.     var content = message.content.toLowerCase();
  22.     return content.startsWith(prefix + command);
  23. }
  24.  
  25. client.on('message', (message) => {
  26.         const args = message.content.slice(prefix.length).trim().split(/ +/g);
  27.         const command = args.shift().toLowerCase()
  28.  
  29.         if(isCommand('Promote', message)){
  30.             var username = args[0]
  31.         var groupId = 4037994;
  32.         var maximumRank = 100;
  33.             if (username){
  34.                 message.channel.send(`Checking ROBLOX for ${username}`)
  35.                 roblox.getIdFromUsername(username)
  36.                 .then(function(id){
  37.                     roblox.getRankInGroup(groupId, id)
  38.                     .then(function(rank){
  39.                         if(maximumRank <= rank){
  40.                             message.channel.send(`${id} is rank ${rank} and not promotable.`)
  41.                         } else {
  42.                             message.channel.send(`${id} is rank ${rank} and promotable.`)
  43.                             roblox.promote(groupId, id)
  44.                             .then(function(roles){
  45.                                 message.channel.send(`Promoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
  46.                             }).catch(function(err){
  47.                                 message.channel.send("Failed to promote.")
  48.                             });
  49.                         }
  50.                     }).catch(function(err){
  51.                         message.channel.send("Couldn't get him in the group.")
  52.                     });
  53.                 }).catch(function(err){
  54.                     message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
  55.                });
  56.            } else {
  57.                message.channel.send("Please enter a username.")
  58.            }
  59.        return;
  60.        }
  61.  
  62.        if(isCommand('Demote', message)){
  63.            var username1 = args[0]
  64.        var groupId = 4037994;
  65.        var minimumRank = 1;
  66.            if (username1){
  67.                message.channel.send(`Checking ROBLOX for ${username1}`)
  68.                roblox.getIdFromUsername(username1)
  69.                .then(function(id){
  70.                    roblox.getRankInGroup(groupId, id)
  71.                    .then(function(rank){
  72.                        if(minimumRank >= rank){
  73.                            message.channel.send(`${id} is rank ${rank} and not demotable.`)
  74.                        } else {
  75.                            message.channel.send(`${id} is rank ${rank} and demotable.`)
  76.                            roblox.demote(groupId, id)
  77.                            .then(function(roles){
  78.                                message.channel.send(`Demoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
  79.                            }).catch(function(err){
  80.                                message.channel.send("Failed to demote.")
  81.                            });
  82.                        }
  83.                    }).catch(function(err){
  84.                        message.channel.send("Couldn't get him in the group.")
  85.                    });
  86.                }).catch(function(err){
  87.                    message.channel.send(`Sorry, but ${username1} doesn't exist on ROBLOX.`)
  88.                });
  89.            } else {
  90.                message.channel.send("Please enter a username.")
  91.            }
  92.        return;
  93.        }
  94.  
  95.        if(isCommand('Shout', message)){
  96.        var groupId = 4037994;
  97.        var shoutMsg = args.join(" ")
  98.        roblox.shout(groupId, shoutMsg)
  99.            .then(function() {
  100.                message.channel.send('Succesfully shouted "'+shoutMsg+'" to the group!')
  101.            })
  102.            .catch(function(err){
  103.                message.channel.send(`Sorry, something went wrong when shouting this message.`)
  104.            });
  105.        }
  106. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement