Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var discord = require('discord.js');
- var roblox = require('roblox-js');
- var client = new discord.Client();
- var token = "NDk4NjQ3NTY5OTkyMjUzNDYw.DpwyhA.p6fAeXVykceMIFYfKQf0TWVC74Y"
- client.login(token)
- roblox.login({username: "SC_Rank", password: "JordanSC03"}).then((success) => {
- }).catch(() => {console.log("Sorry, could not log into SC_Rank.");});
- client.on("ready", () => {
- client.user.setActivity(`Smile Construction`);
- console.log("Thanks for using TigerBots!")
- });
- var prefix = '!';
- function isCommand(command, message){
- var command = command.toLowerCase();
- var content = message.content.toLowerCase();
- return content.startsWith(prefix + command);
- }
- client.on('message', (message) => {
- const args = message.content.slice(prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase()
- if(isCommand('Promote', message)){
- var username = args[0]
- var groupId = 4037994;
- var maximumRank = 100;
- if (username){
- message.channel.send(`Checking ROBLOX for ${username}`)
- roblox.getIdFromUsername(username)
- .then(function(id){
- roblox.getRankInGroup(groupId, id)
- .then(function(rank){
- if(maximumRank <= rank){
- message.channel.send(`${id} is rank ${rank} and not promotable.`)
- } else {
- message.channel.send(`${id} is rank ${rank} and promotable.`)
- roblox.promote(groupId, id)
- .then(function(roles){
- message.channel.send(`Promoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
- }).catch(function(err){
- message.channel.send("Failed to promote.")
- });
- }
- }).catch(function(err){
- message.channel.send("Couldn't get him in the group.")
- });
- }).catch(function(err){
- message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
- });
- } else {
- message.channel.send("Please enter a username.")
- }
- return;
- }
- if(isCommand('Demote', message)){
- var username1 = args[0]
- var groupId = 4037994;
- var minimumRank = 1;
- if (username1){
- message.channel.send(`Checking ROBLOX for ${username1}`)
- roblox.getIdFromUsername(username1)
- .then(function(id){
- roblox.getRankInGroup(groupId, id)
- .then(function(rank){
- if(minimumRank >= rank){
- message.channel.send(`${id} is rank ${rank} and not demotable.`)
- } else {
- message.channel.send(`${id} is rank ${rank} and demotable.`)
- roblox.demote(groupId, id)
- .then(function(roles){
- message.channel.send(`Demoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
- }).catch(function(err){
- message.channel.send("Failed to demote.")
- });
- }
- }).catch(function(err){
- message.channel.send("Couldn't get him in the group.")
- });
- }).catch(function(err){
- message.channel.send(`Sorry, but ${username1} doesn't exist on ROBLOX.`)
- });
- } else {
- message.channel.send("Please enter a username.")
- }
- return;
- }
- if(isCommand('Shout', message)){
- var groupId = 4037994;
- var shoutMsg = args.join(" ")
- roblox.shout(groupId, shoutMsg)
- .then(function() {
- message.channel.send('Succesfully shouted "'+shoutMsg+'" to the group!')
- })
- .catch(function(err){
- message.channel.send(`Sorry, something went wrong when shouting this message.`)
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement