First, the player enters the player’s name and the reason for the report. When everything is ready, the player presses the submit button, and the report should be sent to my Discord server through a webhook, posting the player’s report message from Roblox to my Discord server’s report channel. The problem I’m facing is this error message:
Cannot Send Report: Reason Unable to cast Dictionary to bool
Here is the code:
local WebhookUrl = "https://discord.com/api/webhooks/11..." --I don't want to show my webhook's URL..
local playerNameTextBox = script.Parent:FindFirstChild("playername")
local reasonTextBox = script.Parent:FindFirstChild("reason")
local sendButton = script.Parent:FindFirstChild("submit")
sendButton.MouseButton1Click:Connect(function()
local playerName = playerNameTextBox.Text
local reason = reasonTextBox.Text
if playerName ~= "" and reason ~= "" then
local message = string.format("Player %s reports: %s", playerName, reason)
local data = {
content = message
}
local headers = {
["Content-Type"] = "application/json"
}
local success, response = pcall(function()
return game:GetService("HttpService"):PostAsync(WebhookUrl, game:GetService("HttpService"):JSONEncode(data), Enum.HttpContentType.ApplicationJson, headers)
end)
if success then
if response == "ok" then
print("Report sended successfully")
else
warn("Cannot send report: Error " .. response)
end
else
warn("Cannot Send Report: Reason " .. response)
end
else
warn("You must put player's name and reason")
end
end)
I cannot check what ‘response’ gives me because ‘success’ doesn’t occur and gives the error “Cannot Send Report: Reason Unable to cast Dictionary to bool”
STOP! THIS IS NOT SERVER SITE !!!Any hacker can get your webhook URL super easy, shared it, changed the script, send inappropriate content to the server, spam the channal so that the webhook is blocked from dc and so much more!!!Use remoteevents with cooldowns and server scripts!!!
Also note, Discord blocks HTTP requests from Roblox game servers, so you’ll have to use a proxy such as https://webhook.lewisakura.moe/ to make it work in game.
It seems you are trying to use your webhook in a localscript. This is bad because it won’t work (HTTP request can only be sent from the server), and exploits could steal your webhook URL and use it
That’s the problem, and the hacker has the webhock url and can do on your disvord server what I already meant. There are also other platforms… Therefore serverscript with remoteevents and countdown. More precisely I already said it…
I will do remote-event system but the problem is, how can I keep my webhoock’s URL safe? One person said that I should make a configuration file but i don’t know, how and how it works? I can’t put the url itself into the code because it’s really easy to find the url from there.