Roblox -> Discord Webhook Issue

--Variables
local player = game.Players.LocalPlayer

--UI
local feedbackMain = script.Parent.FeedbackFrame

--Script
local zxc = script.Parent.FeedbackFrame.Frame.TextBox.InputBox.Text

script.Parent.FeedbackFrame.Frame.SendBtn.MouseButton1Click:Connect(function()
	local msg = feedbackMain.Frame.TextBox.InputBox.Text
	local response = game.ReplicatedStorage.FilteringFunction:InvokeServer(msg)
	feedbackMain.Frame.TextBox.InputBox.Text = response
	wait(5)
	script.Parent.FeedbackFrame.Frame.TextBox.InputBox.Text = zxc
end)

script.Parent.FeedbackFrame.ToggleBtn.MouseButton1Click:Connect(function()
	script.Parent.FeedbackFrame.Frame.Visible = not script.Parent.FeedbackFrame.Frame.Visible
end)
script.Parent.FeedbackFrame.Frame.TextBox.InputBox.Text = zxc

Does the textbox say “Feedback recieved!”? Did you do what I said? Like did you add this:

print(InformationToSend)

At the bottom of the JSON encoded dictionary?

By the way why are you filtering the text before sending the messages? It is not like the feedback will be publicly shared to the players and you need curse words censored. Also ROBLOX may censor unwanted things such as numbers. And lastly add a character limit to the feedback UI. Discord cannot send messages with a character limit which is over 2k. Perhaps set it to like 1k or something.

Below the [“content”] and [“username”]?

function RemoteFunction.OnServerInvoke(player, feedback)
	local InformationToSend = HttpService:JSONEncode({
		["content"] = ChatService:FilterStringForBroadcast(feedback, player),
		["username"] = player.Name.. " - (#"..player.UserId..")"
	})
    print(InformationToSend)
	HttpService:PostAsync(Webhook, InformationToSend)
	return "Sent!"
end

By the way after we troubleshoot your script I could help you secure it in DMs.

It prints everything correctly

Alright but show what it prints.

Tried again, it now doesn’t print at all. Can you maybe create a webhook and send link via DMs? Maybe I spammed the requests or something?

That issue has nothing to do with webhooks.

OK, press play and type this in your command bar:

print(game.ReplicatedStorage.FilteringFunction:InvokeServer("test"))

What does it output?

print(game.ReplicatedStorage.FilteringFunction:InvokeServer(“test”))

AKA. It doesn’t

Hm, alright. Replace the .OnServerInvoke thing with this now:

RemoteFunction.OnServerInvoke = function(player, feedback)
	local InformationToSend = {
		["content"] = feedback,
		["username"] = player.Name.. " - (#"..player.UserId..")"
	}
    local newData = HttpService:JSONEncode(InformationToSend)
    local succ, err = pcall(function()
	HttpService:PostAsync(Webhook, newData)
    end)
    if succ then
	return "Sent!"
    else
    return "Error! "..err
    end
end

Now run the same code and tell me the output shows.

HTTP 400 is the error that it returns

From my understanding, your request was sent but something was wrong with it. I think that your username and userid is too long. Try this one:

RemoteFunction.OnServerInvoke = function(player, feedback)
	local InformationToSend = {
		["content"] = feedback,
		["username"] = player.Name
	}
    local newData = HttpService:JSONEncode(InformationToSend)
    local succ, err = pcall(function()
	HttpService:PostAsync(Webhook, newData)
    end)
    if succ then
	return "Sent!"
    else
    return "Error! "..err
    end
end

Worked, thanks for the help! I should have made sure to check the docs for the username limit :blush:

That is fine! No problem. Hit me up on discord so I can help you secure your feedback system.