POST/GET issue for Ban System

Heyyyy! I’m trying to do a ban system and I’m using node.js for website to Post my request via HTTPS. But the problem is how do I made the website to Post the request for ban someone.

I host the website with Heroku.

I’ll sent the script in a edit shortly.

– Services –
local HttpService = game:GetService(“HttpService”)
local Players = game:GetService(“Players”)
local RS = game:GetService(“ReplicatedStorage”)
– Services –

– Modules –
local NotificationModule = require(script.Parent.NotificationModule)
– Modules –

local banEvent = RS.Events.BanPlayer
local unbanEvent = RS.Events.UnbanPlayer

– URLS to send GET/POST requests to –
local checkURL = “https://websiteappbans.herokuapp.com
– URLS to send GET/POST requests to –

–[[ BAN RESPONSE STATUSES ]]–

local module = {}

–[[ BAN FUNCTIONS ]]–o
function module:BanPlayer(senderId, playerId, length, evidence, reason)
local dataFields = {
[“id”] = tostring(playerId);
[“length”] = length;
[“adminid”] = tostring(senderId);
[“reason”] = reason;
[“evidence”] = evidence
}

local URL = "https://websiteappbans.herokuapp.com"
local response = HttpService:PostAsync(URL, HttpService:JSONEncode(dataFields))

local status = HttpService:JSONDecode(response)["status"]
local sender = Players:GetPlayerByUserId(senderId)

print(response)
-- Response status 201 = User banned
if status == 201 then
	local banData = module:GetBanData(playerId)
	
	local success, player = pcall(function()
		return Players:GetPlayerByUserId(playerId)
	end)

	if success and player then
		if banData["unbandate"] == "perm" then
			player:Kick(string.format("\n\nYou have been permanently banned.\nReason: %s\n", banData["reason"]))
		else
			player:Kick(string.format("\n\nYou have been banned.\nReason: %s\nUnban date: %s (UTC)\n", banData["reason"], banData["unbandate"]))
		end
		NotificationModule:NotifyPlayer(sender, string.format("Successfully banned %s!", Players:GetNameFromUserIdAsync(playerId)), "Success")
	else
		NotificationModule:NotifyPlayer(sender, string.format("Successfully banned %s! They are offline, so they will be banned when they rejoin."), "Success")
	end
	
	
-- Response status 304 = User already banned
elseif status == 304 then
	NotificationModule:NotifyPlayer(sender, "That player is already banned!", "Error")
else
	NotificationModule:NotifyPlayer(sender, "An error occurred.", "Error")
end

end

function module:UnbanPlayer(senderId, playerId)
local dataFields = {
[“id”] = tostring(playerId);
[“unban”] = “true”;
[“adminid”] = tostring(senderId);
}

local URL = "https://websiteappbans.herokuapp.com"
local response = HttpService:PostAsync(URL, HttpService:JSONEncode(dataFields))

local status = HttpService:JSONDecode(response)["status"]
local sender = Players:GetPlayerByUserId(senderId)

-- Response status 201 = User unbanned
if status == 201 then
	NotificationModule:NotifyPlayer(sender, string.format("Successfully unbanned %s!", Players:GetNameFromUserIdAsync(playerId)), "Success")
elseif status == 304 then
	NotificationModule:NotifyPlayer(sender, "That player is not banned!", "Error")
else
	NotificationModule:NotifyPlayer(sender, "An error occurred.", "Error")
end

end

function module:GetBanData(playerId)
local getURL = string.format(checkURL, playerId)

local jsonData = HttpService:GetAsync(getURL)
local decodedData = HttpService:JSONDecode(jsonData)

return decodedData

end
–[[ BAN FUNCTIONS ]]–

return module

1 Like

You can’t post to roblox, but one way to do it is long pulling.

The roblox server can send an http request to your server, and your server won’t respond unless you want to ban someone. Once the server responds with someone to ban and the connection terminates, or the connection somehow stops, you immediately send another request.

In this way, you can transfer data to roblox instantly.

Use a DataStore Editing Plugin

Alrighty. I’ll check on it if I can fix it with this!

Where I can found this? Do you have a link for it?

Umm, its probably best just to make a datastore and then just edit it with a script that says whos banned and stuff.

Sorry for the late response, heres the link: DataStore Editor - Roblox
by @Crazyman32

Thank you I’ll look into it! I’m currently making a data store so I hope that will help me!