Whats wrong with my suggestion webhook?

I’m trying to make a suggestion board that when submitted, gets sent to a discord server. The problem is that the script only plays until “Print(“4”)”. What am I doing wrong?

– Server Script (In ServerScriptService)

local webhook = " -- My webhook -- "

local HTTP = game:GetService("HttpService")

local cooldown = 60

local Event = game.ReplicatedStorage.SendFeedback

Event.OnServerEvent:Connect(function(player, message)
	print("1")
	if not script:FindFirstChild(player.Name) then
		print("2")
		local playerValue = Instance.new("BoolValue", script)
		playerValue.Name = player.Name
		print("3")
		local data = {
			["content"] = "New suggestion from: " ..player.Name.. "! They suggest: "..message
		}
		print("4")
		local finaldata = HTTP:JSONEncode(data)
		HTTP:PostAsync(webhook, finaldata)
		print("5")
		task.wait(cooldown)
		script[player.Name]:Destroy()
		print("6")
	end
end)

– Local Script (In StarterCharacterScripts)

local Lobby = game.Workspace:WaitForChild("Lobby")

local holder = Lobby:WaitForChild("MapSuggestions")

local sgui = holder:WaitForChild("SurfaceGui")

local Frame = sgui:WaitForChild("Frame")

local Feedback = Frame:WaitForChild("CommentBox")

local SubmitButton = Frame:WaitForChild("SubmitButton")

SubmitButton.MouseButton1Click:Connect(function()
	if #script.Parent.Parent.Parent.Workspace.Lobby.MapSuggestions.SurfaceGui.Frame.CommentBox.Text >= 5 then
		game.ReplicatedStorage:WaitForChild("SendFeedback"):FireServer(Feedback.Text)
		print("fired")
	end
end)

Are you using a proxy to communicate or directly using the discord endpoint?

1 Like

I’m using a proxy to communicate

try this :

local webhook = "-- Your webhook URL here --"

local HTTP = game:GetService("HttpService")

local cooldown = 60

local Event = game.ReplicatedStorage.SendFeedback

Event.OnServerEvent:Connect(function(player, message)
    print("1")
    if not script:FindFirstChild(player.Name) then
        print("2")
        local playerValue = Instance.new("BoolValue", script)
        playerValue.Name = player.Name
        print("3")
        local data = {
            ["content"] = "New suggestion from: " .. player.Name .. "! They suggest: " .. message
        }
        print("4")
        local finaldata = HTTP:JSONEncode(data)
        local success, err = pcall(function()
          return HTTP:PostAsync(webhook, finaldata, Enum.HttpContentType.ApplicationJson) -- Specify content type
        end)
        print("5")
        task.wait(cooldown)
 script[player.Name]:Destroy()
        print("6")
    end
end)
1 Like

The script still only plays until the Print(“4”) then stops.

Try this, if it doesn’t work it might be because of the proxy you’re using itself

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local WEBHOOK_URL : string = "WEBHOOK_URL"
local CALL_COOLDOWN : number = 60

local SendFeedback = ReplicatedStorage.SendFeedback -- u should organize ur remotes better btw
SendFeedback.OnServerEvent:Connect(function(player : Player, message : string)
    assert(player, "Player is nil")
    assert(message, "Message is nil")

    if script:FindFirstChild(player.Name) then return end

    local playerValue : BoolValue = Instance.new("BoolValue", script)
    playerValue.Name = player.Name

    local CONTENT_DATA = {
        ["content"] = string.format("New suggestion from : %s, Message : %s", player.Name, message or "undefined")
    }
    
    local success, err = pcall(function()
        return HttpService:PostAsync(
            WEBHOOK_URL, 
            HttpService:JSONEncode(CONTENT_DATA),
            Enum.HttpContentType.ApplicationJson
        )
    end)

    if success then
        task.wait(CALL_COOLDOWN)
        script[player.Name]:Destroy()
    else
        error(err)
    end
end)

I recommend making your own proxy or using WebhookProxy | Discord webhooks go brrrrrrr - #28 by lewisakura

1 Like

Can you try printing the result of the http request?

1 Like

How do you know that he didnt make his own?

the script still stops here:

local success, err = pcall(function()
return HttpService:PostAsync(
WEBHOOK_URL,
HttpService:JSONEncode(CONTENT_DATA),
Enum.HttpContentType.ApplicationJson
)
end)

I’ve made my own webhook and turned it into a proxy, and it still doesn’t work. I’ve even tried changing the channels on Discord, but nothing works.

Bump. I really want this to be fixed, I just don’t know how to do it myself.

Try printing the result of the http request

jhrlp

The script doesn’t move past that point

Thank you to everybody for responding. I have found a solution. I had to switch my proxy service to a less popular one, but it works now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.