RoScripter Rank Bot V2 Setup Guide

Hello, RoScripter Members.

I made a V2 System of the Rank bot Since the old system was broken.

Part 1

Setting up the project

Go to https://glitch.com

Click on “New Project”
image

Then Click on “hello-express”
image
After you click on hello-express you will see this example code

// server.js
// where your node app starts

// we've started you off with Express (https://expressjs.com/)
// but feel free to use whatever libraries or frameworks you'd like through `package.json`.
const express = require("express");
const app = express();

// our default array of dreams
const dreams = [
  "Find and count some sheep",
  "Climb a really tall mountain",
  "Wash the dishes"
];

// make all the files in 'public' avaiQlable
// https://expressjs.com/en/starter/static-files.html
app.use(express.static("public"));

// https://expressjs.com/en/starter/basic-routing.html
app.get("/", (request, response) => {
  response.sendFile(__dirname + "/views/index.html");
});

// send the default array of dreams to the webpage
app.get("/dreams", (request, response) => {
  // express helps us take JS objects and send them as JSON
  response.json(dreams);
});

// listen for requests :)
const listener = app.listen(process.env.PORT, () => {
  console.log("Your app is listening on port " + listener.address().port);
});

You want to copy and Paste this code into your glitch.

WAIT

You want to configure the .env File

Click on your .env File
image
Then Click “PlainText”
image
You will see this code

# Environment Config

# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values
# Note: comments will be visible to remixes so don't put secrets in comments!

# reference these in your code with process.env.SECRET

SECRET=
MADE_WITH=

# note: .env is a shell file so there can't be spaces around =
 # Scrubbed by Glitch 2020-10-22T15:38:15+0000

Then remove all of that code inside the .env file.
After you removed it you paste this into the .env file
Paste this code into the .env file

Cookie=""
GroupId=0

Cookie = Your .ROBLOSECURITY
GroupId = Your Roblox Group Id

Exit the .env File then Paste this code into the server.js file:


var noblox = require("noblox.js")
var express = require("express")

const app = express()

app.use(express.static("public"))

app.use(express.json())

app.get('/', function(request,responce){
  responce.json("Ready!")
})
app.post('/ranker/demote', function(request,responce){
    noblox.demote(process.env.GroupId, request.body.userID).catch(function(err){
        if(err) responce.json(JSON.parse(`{"Success": false, "Errors": "${err}"}`))
    })
    responce.json(JSON.parse(`{"Success": true, "Errors": "Nothing"}`))
})

app.post('/group/shout', function(request,responce){
    if(request.body.message !== ''){
        noblox.shout(process.env.GroupId, request.body.message).catch(function(err){
            if(err) responce.json(JSON.parse(`{"Success": false, "Errors": "${err}"}`))
        })
        responce.json(JSON.parse(`{"Success": true, "Errors": "Nothing"}`))
    }
    noblox.shout(process.env.GroupId, request.body.message).catch(function(err){
        if(err) responce.json(JSON.parse(`{"Success": false, "Errors": "${err}"}`))
    })
    responce.json(JSON.parse(`{"Success": true, "Errors": "Nothing"}`))
})

app.post('/ranker/promote/', function(request,responce){
    noblox.promote(process.env.GroupId, request.body.userID).catch(function(err){
        if(err) responce.json(JSON.parse(`{"Success": false, "Errors": "${err}"}`))
    })
    responce.json(JSON.parse(`{"Success": true, "Errors": "Nothing"}`))
})

app.post('/ranker/setRank', function(request,responce){
    noblox.setRank(process.env.GroupId, request.body.userID, request.body.RankID).catch(function(err){
        if(err) responce.json(JSON.parse(`{"Success": false, "Errors": "${err}"}`))
    })
    responce.json(JSON.parse(`{"Success": true, "Errors": "Nothing"}`))
})

app.delete('/group/handleJoinRequest', function(request,responce){
    noblox.handleJoinRequest(process.env.GroupId, request.body.userID, false).catch(function(err){
        if(err) responce.json(JSON.parse(`{"Success": false, "Errors": "${err}"}`))
    })
    responce.json(JSON.parse(`{"Success": true, "Errors": "Nothing"}`))
})

app.post('/group/handleJoinRequest', function(request,responce){
    noblox.handleJoinRequest(process.env.GroupId, request.body.userID, true).catch(function(err){
        if(err) responce.json(JSON.parse(`{"Success": false, "Errors": "${err}"}`))
    })
    responce.json(JSON.parse(`{"Success": true, "Errors": "Nothing"}`))
})

noblox.setCookie(process.env.Cookie)

const listener = app.listen(process.env.PORT, () => {
  console.log("Your app is listening on port " + listener.address().port);
})

After you finished that you want to go to Roblox Studio.

If you have a Group Game you know this already.
For me, I’ll create a new game.
After you are in the game that you are going to Install the Ranking Module.

You will create a Folder in the “ServerScriptStorage” Name the Folder “RankingSystem”

After you created the Folder you Create A ModuleScript and Name it “Config”
Paste this code into it

return {
	GlitchURL = '',
	Rank_AloudToUseCommands = 0,
	GroupID = 0,
	RankPrefix = '',
}

After you did that you want to create another ModuleScript and Name it “Ranking”
Paste this code into the Ranking Module

local http = require(script.Parent.Http)


return {
	denyJoinRequest = function(userId)
		return http.delete('group/handleJoinRequest', game.HttpService:JSONEncode({userID = userId}))
	end;
	acceptJoinRequest = function(userId)
		return http.post('group/handleJoinRequest', game.HttpService:JSONEncode({userID = userId}))
	end;
	shout = function(msg)
		return http.post('group/shout', game.HttpService:JSONEncode({message = msg}))
	end;
	demote = function(userId)
		return http.post('ranker/demote', game.HttpService:JSONEncode({userID = userId}))
	end;
	promote = function(userId)
		return http.post('ranker/promote', game.HttpService:JSONEncode({userID = userId}))
	end;
	setRank = function(userId,rankId)
		return http.post('ranker/setRank', game.HttpService:JSONEncode({userID = userId, RankID = rankId}))
	end
}

After you finished that you want to create another ModuleScript named Http and Paste this code into it.

local config = require(script.Parent.Config)

return {
	delete = function(path,body)
		local Delete = game.HttpService:RequestAsync({
			Url = config.GlitchURL..'/'..path,
			Method = "DELETE",
			Headers = {
				["Content-Type"] = Enum.HttpContentType.ApplicationJson
			},
			Body = body
		})
		local Body = game.HttpService:JSONDecode(Delete.Body)
		if Body.Sucess then
			return true
		end
	end;
	post = function(path,body)
		local POST = game.HttpService:PostAsync(config.GlitchURL..'/'..path,body)
		local Body = game.HttpService:JSONDecode(POST.Body)
		if Body.Sucess then
			return true
		else
			error(Body.Errors)
		end
	end
}

You’re now Finished with everything!

Template

Ranking Chat System
I made one but modified it from the roscripter video.
Create a New Script in the ServerScriptStorage (name it what ever you like)
And paste this code into it

-- Modifed roscripters one

local configs = require(script.Parent.RankingSystem.Config)
local ranking = require(script.Parent.RankingSystem.Ranking)

game.Players.PlayerAdded:Connect(function(Player)
	if Player:GetRankInGroup(configs.GroupID) >= configs.Rank_AloudToUseCommands then
		Player.Chatted:Connect(function(Message)
			local args = string.split(Message, " ")
			if Message == configs.RankPrefix..'promote' then
				local plr = game.Players:GetUserIdFromNameAsync(args[1])
				ranking.promote(plr)
			elseif Message == configs.RankPrefix..'demote' then
				local plr = game.Players:GetUserIdFromNameAsync(args[1])
				ranking.demote(plr)
			elseif Message == configs.RankPrefix..'fire' then
				local plr = game.Players:GetUserIdFromNameAsync(args[1])
				ranking.setRank(plr, 1)
			elseif Message == configs.RankPrefix..'shout' then
				ranking.shout(args[1])
			elseif Message == configs.RankPrefix..'acceptjoinrequest' then
				local plr = game.Players:GetUserIdFromNameAsync(args[1])
				ranking.acceptJoinRequest(plr)
			elseif Message == configs.RankPrefix..'denyjoinrequest' then
				local plr = game.Players:GetUserIdFromNameAsync(args[1])
				ranking.denyJoinRequest(plr)
			elseif Message == configs.RankPrefix..'setrank' then
				local plr = game.Players:GetUserIdFromNameAsync(args[1])
				ranking.setRank(plr, args[2])
			end
		end)
	end
end)
6 Likes