Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const client = new Discord.Client();
- const nbx = require('noblox.js')
- const token = "This is filled in my code"
- const prefix = "?"
- const groupid = 5476584
- const maxRank = 250
- const cookie = "This is filled in my code"
- const minRank = 1
- const shoutRank = 11
- function isCommand(command,message){
- const cmd = command.toLowerCase()
- const content = message.content.toLowerCase()
- return content.startsWith(prefix + cmd)
- };
- client.on('message', message => {
- if (message.author.bot) return;
- if (!message.content.startsWith(prefix)) return;
- var args = message.content.split(/[ ]+/)
- if (isCommand('Setrank', message)){
- var username = args[1]
- let userLen = username.length
- var typeRank = message.content.slice(userLen + 10, 2000)
- if (Number(typeRank)){
- typeRank = Number(typeRank)
- } else {
- message.channel.send("Please use the Rank Number to change their rank!")
- }
- if (username){
- nbx.getIdFromUsername(username)
- .then(function(id){
- nbx.getRankInGroup(groupid,id)
- .then(function(grank){
- if (grank >= maxRank){
- message.channel.send("This user's rank is already at the highest rank! Their rank has to be changed manually!")
- } else {
- if (typeRank) {
- nbx.setRank({group: groupid, target: id, rank: typeRank})
- .then(function(roles){
- message.channel.send("New Rank: " + typeRank)
- }).catch(function(error){
- message.channel.send("That Role Does Not Exist!")
- console.log(error);
- })
- } else {
- message.channel.send("Make Sure The Rank Name Exists And Is A Name!")
- }
- }
- }).catch(function(error){
- message.channel.send("That User Is Not In The Group!")
- console.log(error);
- })
- }).catch(function(error){
- message.channel.send("That User Does Not Exist!")
- console.log(error);
- })
- }
- }
- }
Add Comment
Please, Sign In to add comment