We have a good tutorial by @cam regarding web hooks: Tutorial - How to send a message from Roblox to Discord (webhooks) - Tutorial - Cookie Tech (thecookie.dev)
Something like this should work:
local HttpService = game:GetService("HttpService")
local ReplicatedStorage = game.ReplicatedStorage
local AppUrl = script.AppUrl.Value
local ApiKey = script.ApiKey.Value
local Groupid = script.GroupId.Value
local MinRank = script.MinRank.Value
local prefix = "!"
local WebhookUrl = ""
local function UpdateStatus(status, user)
if status == true then
local data = {
['content'] = user.." got promoted!"}
httpService:PostAsync(webhookUrl,httpService:JSONEncode(data))
else
local data = {
['content'] = user.." got demoted!"}
httpService:PostAsync(webhookUrl,httpService:JSONEncode(data))
end
local function FindPlr(plr)
local foundPlr = nil
local plrs = game.Players:GetPlayers()
for i = 1, #plrs do
local current = plrs[i]
if string.lower(current.Name):sub(1, #plr) == string.lower(plr) then
foundPlr = current.Name
break
end
end
return foundPlr
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if player:GetRankInGroup(Groupid) >= 254 then
local LowerCaseMessage = string.lower(msg)
if string.find(LowerCaseMessage, "!promote") then
local SplitMessage = string.split(msg, " ")
local full_player = FindPlr(SplitMessage[2])
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name)
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Error!","We couldn't find the player you wanted to promote!")
else
local playerInstance = game.Players:FindFirstChild(player.Name)
local Url = script.AppUrl.Value.."group/promote?user_name="..full_player.."&key=" ..script.ApiKey.Value.."&groupid="..script.GroupId.Value
local success, response = pcall(function()
local response = HttpService:GetAsync(Url)
local data = HttpService:JSONDecode(response)
end)
if success then
UpdateStatus(true, playerInstance )
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Success!","User has been promoted!")
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Error!","We ran into some problems.")
end
end
else if string.find(LowerCaseMessage, "!demote") then
local SplitMessage = string.split(msg, " ")
local full_player = FindPlr(SplitMessage[2])
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name)
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Error!","We couldn't find the player you wanted to demote!")
else
local playerInstance = game.Players:FindFirstChild(player.Name)
local Url = script.AppUrl.Value.."group/demote?user_name="..full_player.. "&key=" ..script.ApiKey.Value.. "&groupid=" ..script.GroupId.Value
local success, response = pcall(function()
local response = HttpService:GetAsync(Url)
local data = HttpService:JSONDecode(response)
end)
if success then
UpdateStatus(false, playerInstance )
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Success!","User has been demoted!")
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Error!","We ran into some problems.")
end
end
end
end
end
end)
end)